package com.dragon.mmochat.model.role;

import java.awt.Color;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;

import com.dragon.mmochat.MmochatConstant;
import com.dragon.mmochat.MmochatMain;
import com.dragon.mmochat.message.Mmochat_1_10S;
import com.dragon.mmochat.message.Mmochat_1_20S;
import com.dragon.mmochat.message.Mmochat_1_32S;
import com.dragon.mmochat.message.Mmochat_4_14S;
import com.dragon.mmochat.message.Mmochat_5_1S;
import com.dragon.mmochat.message.Mmochat_5_31S;
import com.dragon.mmochat.model.MmochatChenHao;
import com.dragon.mmochat.model.MmochatDailyActivity;
import com.dragon.mmochat.model.MmochatLevelHint;
import com.dragon.mmochat.model.MmochatSerial;
import com.dragon.mmochat.model.MmochatStrengthDrug;
import com.dragon.mmochat.model.MmochatTeam;
import com.dragon.mmochat.model.battle.MmochatBattleOrder;
import com.dragon.mmochat.model.battle.MmochatSme;
import com.dragon.mmochat.model.deal.MmochatDeal;
import com.dragon.mmochat.model.enumType.MmochatChatChannelType;
import com.dragon.mmochat.model.enumType.MmochatChenHaoType;
import com.dragon.mmochat.model.enumType.MmochatCommonObjectType;
import com.dragon.mmochat.model.enumType.MmochatDailyActivityType;
import com.dragon.mmochat.model.enumType.MmochatDrugType;
import com.dragon.mmochat.model.enumType.MmochatEquipAttributeType;
import com.dragon.mmochat.model.enumType.MmochatEquipGiftType;
import com.dragon.mmochat.model.enumType.MmochatEquipPlaceType;
import com.dragon.mmochat.model.enumType.MmochatFamilyType;
import com.dragon.mmochat.model.enumType.MmochatBattleOrderType;
import com.dragon.mmochat.model.enumType.MmochatGangSkillType;
import com.dragon.mmochat.model.enumType.MmochatLifeSkillType;
import com.dragon.mmochat.model.enumType.MmochatMaterialType;
import com.dragon.mmochat.model.enumType.MmochatObjectType;
import com.dragon.mmochat.model.enumType.MmochatOtherSystemSettingType;
import com.dragon.mmochat.model.enumType.MmochatPackageGridType;
import com.dragon.mmochat.model.enumType.MmochatPetStateType;
import com.dragon.mmochat.model.enumType.MmochatPropEffectType;
import com.dragon.mmochat.model.enumType.MmochatPropType;
import com.dragon.mmochat.model.enumType.MmochatRoleBmpType;
import com.dragon.mmochat.model.enumType.MmochatRoleMotionStateType;
import com.dragon.mmochat.model.enumType.MmochatRoleStateType;
import com.dragon.mmochat.model.enumType.MmochatRoleType;
import com.dragon.mmochat.model.enumType.MmochatSecondRoleType;
import com.dragon.mmochat.model.enumType.MmochatShowRoleSet;
import com.dragon.mmochat.model.enumType.MmochatSkillType;
import com.dragon.mmochat.model.enumType.MmochatSmeResult;
import com.dragon.mmochat.model.enumType.MmochatSmeType;
import com.dragon.mmochat.model.enumType.MmochatSpecialSkillType;
import com.dragon.mmochat.model.enumType.MmochatStorePwdState;
import com.dragon.mmochat.model.enumType.MmochatSuperMachineType;
import com.dragon.mmochat.model.enumType.MmochatTaskStateType;
import com.dragon.mmochat.model.enumType.MmochatTaskType;
import com.dragon.mmochat.model.enumType.MmochatTeamStateType;
import com.dragon.mmochat.model.gang.MmochatGangSkill;
import com.dragon.mmochat.model.map.MmochatMovePoint;
import com.dragon.mmochat.model.object.MmochatCommonObject;
import com.dragon.mmochat.model.object.MmochatMaterial;
import com.dragon.mmochat.model.object.MmochatPackageGrid;
import com.dragon.mmochat.model.object.MmochatPropEffect;
import com.dragon.mmochat.model.skill.MmochatSkill;
import com.dragon.mmochat.model.skill.MmochatSpecialSkill;
import com.dragon.mmochat.model.skill.lifeSkill.MmochatLifeSkill;
import com.dragon.mmochat.model.task.MmochatTask;
import com.dragon.mmochat.service.MmochatBattleService;
import com.dragon.mmochat.service.MmochatChatService;
import com.dragon.mmochat.service.MmochatDao;
import com.dragon.mmochat.service.MmochatDealService;
import com.dragon.mmochat.service.MmochatFriendService;
import com.dragon.mmochat.service.MmochatMainService;
import com.dragon.mmochat.service.MmochatNpcService;
import com.dragon.mmochat.service.MmochatPetService;
import com.dragon.mmochat.service.MmochatTaskService;
import com.dragon.mmochat.service.MmochatTeamService;
import com.dragon.mmochat.util.MmochatUtil;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.skymobi.message.SkymobiProtocolMessage.UserConnInfo;

//TODO:注意点
//1、如果二阶属性计算公式改变了，那么在生成怪物BOSS属性，计算战绩输赢里(包括逃跑扣战绩)都需要相应修改
//2、反GSON时，一些concurrentHashMap的变量会变成LinkedHashMap，需要转化回来，否则会被并发异常
public class MmochatPlayer implements MmochatRole, Cloneable,
		Comparable<MmochatPlayer> {
	private static final long serialVersionUID = -2022724927519046525L;
	// 游客临时ID生成:游客在服务器维护周期内最多允许有400万个
	public static MmochatSerial guestSerial = new MmochatSerial(
			MmochatConstant.guestRoleIdStart);

	/*********** 数据库字段 ***********/
	private int roleId;
	private boolean deleted = false; // 删号标志
	private long skyId = 0;
	private String name;
	private int level = 0;
	private int exp = 0;
	private int sexual = 0;
	private MmochatRoleType roleType;
	private MmochatRoleBmpType curRoleBmpType = MmochatRoleBmpType.官;// 战斗中使用，不用存数据库
	private int mapId = 0;
	private int line = 0;
	private int x = 0;
	private int y = 0;
	private int curBlood; // 当前血量,总血量通过计算得到
	private int curSprit; // 当前灵力,总灵力通过计算得到
	private int blood_point = 0; // 体质
	private int attack_point = 0; // 力量
	private int sprit_point = 0; // 灵力
	private int speed_point = 0; // 敏捷
	private int space_point = 0; // 可分配点数
	private int attack_gift_point = 0; // 天赋·野蛮
	private int sprit_gift_point = 0; // 天赋·智慧
	private int blood_gift_point = 0; // 天赋·活力
	private int defend_gift_point = 0; // 天赋·坚韧
	private int speed_gift_point = 0; // 天赋·灵巧
	private int space_gift_point = 0; // 可分配天赋点
	private int dao = 0; // 道行
	private long small_money = 0; // 普通游戏币
	private long big_money = 0; // K币兑换而来的币
	private MmochatFamilyType family; // 门派
	private int zhanji = 0; // 战绩
	private int login_time = 0; // 登陆次数
	private long latest_login_time = 0; // 最近一次登陆时间Date.getTime()
	private long latest_offline_time = 0; // 最近一次离线时间Date.getTime()
	private int bmpId = 0; // 列表头像图标
	private String moodInfo = null; // 个性签名
	private int gangId = -1; // 帮派ID
	private int pkteam_id = -1; // 战队ID
	private int teacherScore = 0; // 师德值
	private int max_screen_role_num = 20; // 同屏显示玩家人数上限
	private int cur_month_login_day_num = 1; // 本月登陆天数
	private long createTime; // 创建角色的时间
	private int rest_award_times = 0; // 剩余抽奖次数
	private int account_bigmoney = 0; // 元宝交易账户中的元宝数
	private int account_smallmoney = 0; // 元宝交易账户中的金钱数
	private int lottery = 0; // 奖券数
	private int sustainedLotteryDays = 0;// 连续领奖券天数
	private long lastLotteryTime = 0;// 最后领奖券日期
	private int total_pay = 0; // 总充值金额
	private int life_turn = 0; // 转生次数
	private MmochatSecondRoleType second_role_type = MmochatSecondRoleType.未转生;
	private long lock_time_point = 0; // 锁定时间，在此时间之前，不允许登陆
	private long honor = 0; // 声望
	private String store_pwd = ""; // 仓库密码
	private MmochatStorePwdState store_pwd_state = MmochatStorePwdState.未设置钱庄密码;
	private long releaseStorePwdTime = 0;// 清除钱庄密码开始时间
	private boolean hasCheckStorePwd = false;
	private long extra = 0;
	private long limit_bigmoney = 0;// 不可交易的元宝数(通过元宝交易获得的元宝，无法再次进行交易)
	private int fuBenId = 0;// 当前副本ID
	private int pk_score = 0; // 跨服竞技点
	private long latest_pay_time = 0;// 最后一次付费时间

	// 当前所有任务列表
	private Map<Integer, MmochatTask> tasks = new ConcurrentHashMap<Integer, MmochatTask>();
	// 宠物
	private Map<Integer, MmochatPet> pets = new ConcurrentHashMap<Integer, MmochatPet>();

	// 包裹:格子序号->包裹格子
	private Map<Integer, MmochatPackageGrid> myPackage = new ConcurrentHashMap<Integer, MmochatPackageGrid>();

	// 我的仓库:格子序号-->仓库格子
	private Map<Integer, MmochatPackageGrid> myStorage = new ConcurrentHashMap<Integer, MmochatPackageGrid>();
	// 仓库游戏币
	private int storedSmall_money = 0;
	// 仓库宠物
	private Map<Integer, MmochatPet> storedPets = new ConcurrentHashMap<Integer, MmochatPet>();

	// 技能列表
	private Map<MmochatSkillType, MmochatSkill> skills = new ConcurrentHashMap<MmochatSkillType, MmochatSkill>();

	// 特殊技能列表
	private Map<MmochatSpecialSkillType, MmochatSpecialSkill> specialSkills = new ConcurrentHashMap<MmochatSpecialSkillType, MmochatSpecialSkill>();

	// 生活技能列表
	private Map<MmochatLifeSkillType, MmochatLifeSkill> lifeSkills = new ConcurrentHashMap<MmochatLifeSkillType, MmochatLifeSkill>();

	// 帮派技能
	private Map<MmochatGangSkillType, MmochatGangSkill> gangSkills = new ConcurrentHashMap<MmochatGangSkillType, MmochatGangSkill>();
	// 我的好友:roleId->好友基本信息
	private Map<Integer, MmochatFriend> myDearFriends = new ConcurrentHashMap<Integer, MmochatFriend>();
	// 黑名单:roleId->好友基本信息
	private Map<Integer, MmochatFriend> myEnermys = new ConcurrentHashMap<Integer, MmochatFriend>();
	// 临时好友
	private transient ArrayBlockingQueue<MmochatFriend> myTempFriends = new ArrayBlockingQueue<MmochatFriend>(
			MmochatConstant.maxTempFriendNum);
	private Map<Integer, MmochatFriend> myTempFriendsMap = new ConcurrentHashMap<Integer, MmochatFriend>();
	// 终端临时好友影像
	private Map<Integer, MmochatFriend> myTempFriendsBak = new ConcurrentHashMap<Integer, MmochatFriend>();
	// 加我为好友的所有人(可能我并没有加对方)
	private Map<Integer, Integer> myFans = new ConcurrentHashMap<Integer, Integer>();
	// 我关注的好友(上下线提醒)
	private Map<Integer, Integer> myIdols = new ConcurrentHashMap<Integer, Integer>();

	// 我的师傅
	private int teacher_roleId = -1;
	private String teacher_name = null;

	// 我的徒弟,roleId->name
	private Map<Integer, String> students = new ConcurrentHashMap<Integer, String>();

	// 我的配偶
	private int wife_roleId = -1;
	private String wife_name = null;

	// 日常活动
	private Map<MmochatDailyActivityType, MmochatDailyActivity> dailyActivities = new ConcurrentHashMap<MmochatDailyActivityType, MmochatDailyActivity>();

	// 道具效果:effectKey->MmochatPropEffect
	private Map<Integer, MmochatPropEffect> propEffects = new ConcurrentHashMap<Integer, MmochatPropEffect>();

	// 显示玩家设置;此项保存数据库是为了防止玩家掉线重连后此设置被重设
	private MmochatShowRoleSet showRoleSet = MmochatShowRoleSet.显示所有人;

	// 显示的聊天频道, 频道-->是否显示;此项保存数据库是为了防止玩家掉线重连后此设置被重设
	private Map<MmochatChatChannelType, Boolean> showChatSet = new ConcurrentHashMap<MmochatChatChannelType, Boolean>();

	// 是否接受切磋
	private boolean acceptFriendlyPk = true;

	// 是否接受比武
	private boolean acceptZhanjiPk = true;

	// 是否接受陌生人消息
	private boolean acceptStrangerMessage = true;

	// 是否验证添加好友
	private boolean checkAddMeFriend = false;

	// 是否接受加为好友
	private boolean acceptAddMeFriend = true;

	private long lastGetVipDoublePropTime = 0; // 上一次领取VIP双倍的时间

	private String suggestName = null; // 推荐人

	private String imei = null; // 手机识别码

	private int suggestScore = 0; // 我的推荐人积分

	// 其它系统设置
	private Map<MmochatOtherSystemSettingType, Boolean> otherSystemSetting = new ConcurrentHashMap<MmochatOtherSystemSettingType, Boolean>();

	// 称号列表:称号类型-->称号
	private Map<MmochatChenHaoType, MmochatChenHao> chenHaoMap = new ConcurrentHashMap<MmochatChenHaoType, MmochatChenHao>();

	/*********** 内存数据 ***********/
	// 用于判断掉线
	private transient UserConnInfo userConnInfo = null;
	private long latestActiveTime = System.currentTimeMillis();

	// 角色已掉线.但未从角色列表中删除(可能正在战斗中)
	private boolean deadConnection = false;

	// 坐标缓存器:缓存其它角色的移动坐标,定时下发
	// roleId->point
	// 切换地图或重连后要清空坐标缓存器;
	// 当角色已经不在sceenRoles时直接从缓存器中清除而不下发;
	// 当角色与this超出同屏时,下发本次坐标，下发后清除(超出同屏的可以作批量下发删除角色处理)
	private transient Map<Integer, MmochatMovePoint> positionBuffer = new ConcurrentHashMap<Integer, MmochatMovePoint>();

	// 最近一次角色的活动时间
	// 玩家5分钟没有活动时,自动进入省流量模式,此模式下只接收系统消息,不接收其它频道聊天。不接受玩家走动信息
	// 玩家再次移动后自动解除此模式
	private AtomicLong lastActionTime = new AtomicLong(System
			.currentTimeMillis());
	private boolean microNetFlowMode = false;

	// 视界内的角色:roleId->Value
	private Map<Integer, Long> sceenRoles = new ConcurrentHashMap<Integer, Long>();

	// 视界内的临时npc,如boss,鬼,海盗等+所有地图固定NPC
	private Map<Integer, Integer> tmpNpcs = new ConcurrentHashMap<Integer, Integer>();

	// 回合战斗中使用
	private int battleId = 0; // 0表示没在战斗, >0战场ID
	private int watchBattleId = 0; // 0表示没在观战，>0表示观战的战场ID
	private int curPkBlood; // 当前战斗中的血量
	private int curPkSprit; // 当前战斗中的灵力
	private boolean useDefendInPk = false; // 在本回合中使用了防御
	private boolean isDeadInBattle = false; // 是否在战斗中死亡

	// 动画类别-->保持回合数
	private Map<MmochatSmeType, MmochatSme> sme = new ConcurrentHashMap<MmochatSmeType, MmochatSme>(); // 动画

	// 战斗指令类型-->战斗指令
	private Map<MmochatBattleOrderType, MmochatBattleOrder> battleOrders = new ConcurrentHashMap<MmochatBattleOrderType, MmochatBattleOrder>();

	// 交易ID
	private int dealId = 0; // 0表示没在交易中

	// 队伍ID
	private int teamId = 0; // 0表示没有队伍

	// 一些不能并发的状态
	private MmochatRoleStateType state = MmochatRoleStateType.空闲;

	// 最近一次一键补血补蓝时间,防止频繁补血补蓝
	private AtomicLong latestAutoAddBloodSpritTime = new AtomicLong(0);

	// 好友上下线后更新好友列表缓存器
	private Map<Integer, Integer> onlineFriends = new ConcurrentHashMap<Integer, Integer>();
	private Map<Integer, Integer> offlineFriends = new ConcurrentHashMap<Integer, Integer>();

	// 临时比赛积分
	private int commonActivityScore = 0;

	// 上次取消帮派任务的时间
	private long lastTimeOfCancelGangTask = System.currentTimeMillis();

	// 是否锁定切换地图；锁定后忽略终端切换地图消息
	private boolean lockTrans = false;

	// 最近一次接收世界聊天的时间
	private long lastTimeOfReceiveWorldChat = 0;

	// 上一次世界聊天发言的时间
	private long lastTimeOfWorldChat = System.currentTimeMillis()
			- MmochatConstant.minIntervalOfWorldChat;

	// 上一次私聊发言的时间
	private long lastTimeOfPrivateChat = System.currentTimeMillis()
			- MmochatConstant.minIntervalOfPrivateChat;

	// 玩家当前可发言条数
	private int freeWorldChatNum = MmochatConstant.worldChatBufferSize;

	// 上次增加发言机会的时候
	private long lastTimeOfAddChatNum = System.currentTimeMillis();

	// 最近一次发起远程交易请求的时间(每隔30秒才能发起一次)
	private long lastTimeOfRemoteDeal = System.currentTimeMillis();

	// 最近一次整理仓库或包裹的时间
	private long lastOrderStorageTick = 0;

	// 最近一次接收人物走动数据的时间
	private long lastTimeOfReceiveMotionData = System.currentTimeMillis();

	// 能否允许进入战斗
	private boolean canEnterBattle = true;

	// 玩家的终端版本
	private int clientVersion = -1;

	// 消息发向哪个实例号
	private int serverInstId = MmochatMain.getModuleInstID();

	// 玩家注册时所在区服
	private int regServerInstId = MmochatMain.getModuleInstID();

	// 被监控的道具的当前合理数量(包裹+仓库)
	private int monitorPropNum = 0;

	// 上次在线领奖时间
	private long lastOnlineAwardTick = System.currentTimeMillis();

	// 心跳包统计开始时间(每10分钟重置一次)
	private long heartBeatStartTick = System.currentTimeMillis();

	// 心跳包次数(每10分钟重置一次)
	private int heartBeatTimes = 0;

	// 最近一次录像ID
	private int recordBattleId = 0;

	/*********************************************************************/
	public MmochatPlayer() {
		for (MmochatChatChannelType type : MmochatChatChannelType.values()) {
			showChatSet.put(type, true);
		}
	}

	// 设置游客ID
	public void setGuestRoleId() {
		roleId = guestSerial.addAndGetSerialId();
	}

	// 是否为游客
	public boolean isGuest() {
		return roleId >= MmochatConstant.guestRoleIdStart && roleId < 10000000;
	}

	// 角色第一次进入游戏时进行一次初始化
	public void initWhenFirstTimeLogin() {
		// 初始化包裹格子
		for (int i = MmochatConstant.packageGridIndexHead; i <= MmochatConstant.nonVipPackageGridIndexTail; i++) {
			MmochatPackageGrid grid = new MmochatPackageGrid();
			grid.setCanUse(true);
			grid.setGridIndex(i);
			grid.setGridType(MmochatPackageGridType.包裹物品格子);
			myPackage.put(grid.getGridIndex(), grid);
		}
		for (int i = MmochatConstant.nonVipPackageGridIndexTail + 1; i <= MmochatConstant.vipPackageGridIndexTail; i++) {
			MmochatPackageGrid grid = new MmochatPackageGrid();
			grid.setCanUse(false);
			grid.setGridIndex(i);
			grid.setGridType(MmochatPackageGridType.包裹物品格子);
			myPackage.put(grid.getGridIndex(), grid);
		}
		for (MmochatEquipPlaceType place : MmochatEquipPlaceType.values()) {
			MmochatPackageGrid grid = new MmochatPackageGrid();
			grid.setCanUse(true);
			grid.setGridIndex(place.getValue());
			grid.setGridType(MmochatPackageGridType.身上装备格子);
			myPackage.put(grid.getGridIndex(), grid);
		}

		// 初始化仓库格子
		for (int i = MmochatConstant.storageGridIndexHead; i <= MmochatConstant.storageGridIndexTail; i++) {
			MmochatPackageGrid grid = new MmochatPackageGrid();
			grid.setCanUse(true);
			grid.setGridIndex(i);
			grid.setGridType(MmochatPackageGridType.仓库物品格子);
			myStorage.put(grid.getGridIndex(), grid);
		}
	}

	// 当玩家正常进入游戏时(非掉线重连),进行一些初始化设置
	public void initNormalEnterGame() {
		showRoleSet = MmochatShowRoleSet.显示所有人;
		// for (MmochatChatChannelType type : MmochatChatChannelType.values()) {
		// showChatSet.put(type, true);
		// }
		// 临时好友清空
		myTempFriends.clear();
		// 终端临时好友影像清空
		myTempFriendsBak.clear();

		lockTrans = false;

		serverInstId = MmochatMain.getModuleInstID();
	}

	public static int getRealRoleId(int curRoleId) {
		// return curRoleId % 10000000;
		return curRoleId;
	}

	public int getRealRoleId() {
		// return roleId % 10000000;
		return roleId;
	}

	public MmochatPlayer getClone() {
		MmochatPlayer clone = null;
		try {
			clone = (MmochatPlayer) MmochatUtil.deepClone(this,
					new TypeToken<MmochatPlayer>() {
					}.getType());
			clone.setUserConnInfo(userConnInfo);

			clone.tasks = new ConcurrentHashMap<Integer, MmochatTask>(clone
					.getTasks());
			clone.pets = new ConcurrentHashMap<Integer, MmochatPet>(clone
					.getPets());
			clone.myPackage = new ConcurrentHashMap<Integer, MmochatPackageGrid>(
					clone.getMyPackage());
			clone.myStorage = new ConcurrentHashMap<Integer, MmochatPackageGrid>(
					clone.getMyStorage());
			clone.storedPets = new ConcurrentHashMap<Integer, MmochatPet>(clone
					.getStoredPets());
			clone.skills = new ConcurrentHashMap<MmochatSkillType, MmochatSkill>(
					clone.getSkills());
			clone.specialSkills = new ConcurrentHashMap<MmochatSpecialSkillType, MmochatSpecialSkill>(
					clone.getSpecialSkills());
			clone.lifeSkills = new ConcurrentHashMap<MmochatLifeSkillType, MmochatLifeSkill>(
					clone.getLifeSkills());
			clone.gangSkills = new ConcurrentHashMap<MmochatGangSkillType, MmochatGangSkill>(
					clone.getGangSkills());
			clone.myDearFriends = new ConcurrentHashMap<Integer, MmochatFriend>(
					clone.getMyDearFriends());
			clone.myEnermys = new ConcurrentHashMap<Integer, MmochatFriend>(
					clone.getMyEnermys());
			clone.myTempFriendsMap = new ConcurrentHashMap<Integer, MmochatFriend>(
					clone.getMyTempFriendsMap());
			clone.myTempFriendsBak = new ConcurrentHashMap<Integer, MmochatFriend>(
					clone.getMyTempFriendsBak());
			clone.myFans = new ConcurrentHashMap<Integer, Integer>(clone
					.getMyFans());
			clone.myIdols = new ConcurrentHashMap<Integer, Integer>(clone
					.getMyIdols());
			clone.students = new ConcurrentHashMap<Integer, String>(clone
					.getStudents());
			clone.dailyActivities = new ConcurrentHashMap<MmochatDailyActivityType, MmochatDailyActivity>(
					clone.getDailyActivities());
			clone.propEffects = new ConcurrentHashMap<Integer, MmochatPropEffect>(
					clone.getPropEffects());
			clone.showChatSet = new ConcurrentHashMap<MmochatChatChannelType, Boolean>(
					clone.getShowChatSet());
			clone.sceenRoles = new ConcurrentHashMap<Integer, Long>(clone
					.getSceenRoles());
			clone.tmpNpcs = new ConcurrentHashMap<Integer, Integer>(clone
					.getTmpNpcs());
			clone.sme = new ConcurrentHashMap<MmochatSmeType, MmochatSme>(clone
					.getSme());
			clone.battleOrders = new ConcurrentHashMap<MmochatBattleOrderType, MmochatBattleOrder>(
					clone.battleOrders);
			clone.onlineFriends = new ConcurrentHashMap<Integer, Integer>(clone
					.getOnlineFriends());
			clone.offlineFriends = new ConcurrentHashMap<Integer, Integer>(
					clone.getOfflineFriends());
			clone.otherSystemSetting = new ConcurrentHashMap<MmochatOtherSystemSettingType, Boolean>(
					clone.getOtherSystemSetting());
		} catch (Exception e) {
			e.printStackTrace();
			clone = (MmochatPlayer) MmochatUtil.deepClone(this);
			clone.setUserConnInfo(userConnInfo);

			clone.tasks = new ConcurrentHashMap<Integer, MmochatTask>(clone
					.getTasks());
			clone.pets = new ConcurrentHashMap<Integer, MmochatPet>(clone
					.getPets());
			clone.myPackage = new ConcurrentHashMap<Integer, MmochatPackageGrid>(
					clone.getMyPackage());
			clone.myStorage = new ConcurrentHashMap<Integer, MmochatPackageGrid>(
					clone.getMyStorage());
			clone.storedPets = new ConcurrentHashMap<Integer, MmochatPet>(clone
					.getStoredPets());
			clone.skills = new ConcurrentHashMap<MmochatSkillType, MmochatSkill>(
					clone.getSkills());
			clone.specialSkills = new ConcurrentHashMap<MmochatSpecialSkillType, MmochatSpecialSkill>(
					clone.getSpecialSkills());
			clone.lifeSkills = new ConcurrentHashMap<MmochatLifeSkillType, MmochatLifeSkill>(
					clone.getLifeSkills());
			clone.gangSkills = new ConcurrentHashMap<MmochatGangSkillType, MmochatGangSkill>(
					clone.getGangSkills());
			clone.myDearFriends = new ConcurrentHashMap<Integer, MmochatFriend>(
					clone.getMyDearFriends());
			clone.myEnermys = new ConcurrentHashMap<Integer, MmochatFriend>(
					clone.getMyEnermys());
			clone.myTempFriendsMap = new ConcurrentHashMap<Integer, MmochatFriend>(
					clone.getMyTempFriendsMap());
			clone.myTempFriendsBak = new ConcurrentHashMap<Integer, MmochatFriend>(
					clone.getMyTempFriendsBak());
			clone.myFans = new ConcurrentHashMap<Integer, Integer>(clone
					.getMyFans());
			clone.myIdols = new ConcurrentHashMap<Integer, Integer>(clone
					.getMyIdols());
			clone.students = new ConcurrentHashMap<Integer, String>(clone
					.getStudents());
			clone.dailyActivities = new ConcurrentHashMap<MmochatDailyActivityType, MmochatDailyActivity>(
					clone.getDailyActivities());
			clone.propEffects = new ConcurrentHashMap<Integer, MmochatPropEffect>(
					clone.getPropEffects());
			clone.showChatSet = new ConcurrentHashMap<MmochatChatChannelType, Boolean>(
					clone.getShowChatSet());
			clone.sceenRoles = new ConcurrentHashMap<Integer, Long>(clone
					.getSceenRoles());
			clone.tmpNpcs = new ConcurrentHashMap<Integer, Integer>(clone
					.getTmpNpcs());
			clone.sme = new ConcurrentHashMap<MmochatSmeType, MmochatSme>(clone
					.getSme());
			clone.battleOrders = new ConcurrentHashMap<MmochatBattleOrderType, MmochatBattleOrder>(
					clone.getBattleOrders());
			clone.onlineFriends = new ConcurrentHashMap<Integer, Integer>(clone
					.getOnlineFriends());
			clone.offlineFriends = new ConcurrentHashMap<Integer, Integer>(
					clone.getOfflineFriends());
			clone.otherSystemSetting = new ConcurrentHashMap<MmochatOtherSystemSettingType, Boolean>(
					clone.getOtherSystemSetting());
		}
		return clone;
	}

	public long getSkyId() {
		return skyId;
	}

	public void setSkyId(long skyId) {
		this.skyId = skyId;
	}

	public UserConnInfo getUserConnInfo() {
		return userConnInfo;
	}

	public void setUserConnInfo(UserConnInfo userConnInfo) {
		this.userConnInfo = userConnInfo;
	}

	public long getLatestActiveTime() {
		return latestActiveTime;
	}

	public void setLatestActiveTime(long latestActiveTime) {
		this.latestActiveTime = latestActiveTime;
	}

	public int getSexual() {
		return sexual;
	}

	public void setSexual(int sexual) {
		this.sexual = sexual;
	}

	public int getRoleId() {
		return roleId;
	}

	public void setRoleId(int roleId) {
		this.roleId = roleId;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getLevel() {
		return level;
	}

	public void setLevel(int level) {
		this.level = level;
	}

	public int getTrueLevel() {
		return level + life_turn * 10;
	}

	public String getLevelInfo() {
		String info = "";
		if (life_turn > 0) {
			info += life_turn + "转";
		}
		info += level + "级";
		return info;
	}

	public int getExp() {
		return exp;
	}

	public void setExp(int exp) {
		this.exp = exp;
	}

	// 增加等级(不能扣减，同时增加属性点、天赋点)
	public void addLevelAndAttr(int addLevel) {
		if (addLevel <= 0) {
			return;
		}
		int oldGiftNum = level / 2;
		int trueAdd = Math.min(MmochatConstant.maxLevel - level, addLevel);
		level += trueAdd;
		blood_point += trueAdd;
		sprit_point += trueAdd;
		attack_point += trueAdd;
		speed_point += trueAdd;
		space_point += 4 * trueAdd;
		int addGiftNum = level / 2 - oldGiftNum;
		space_gift_point += addGiftNum;
		curBlood = getTotalBlood();
		curSprit = getTotalSprit();
	}

	// 增加经验，不进行升级
	public void addExpWithoutUplevel(int add) {
		exp += add;
	}

	// 增加经验后,需要自行保存数据库
	public boolean addExp(int add) {
		return addExp((long) add);
	}

	public boolean addExp(long add) {
		if (add > 0 && hasPropEffect(MmochatPropType.经验冻结丹.getEffectKey())) {
			return false;
		}
		boolean upLevel = false;
		long ret = (long) exp + add;
		exp = (int) Math.min(ret, Integer.MAX_VALUE);
		if (exp < 0) {
			exp = 0;
		}
		if (level < MmochatConstant.maxLevel) {
			int uplevelExp = MmochatBattleService.getHumanExpNeedToUplevel(
					level, life_turn);
			if (exp >= uplevelExp) {
				// 升级
				exp -= uplevelExp;
				level++;
				blood_point++;
				sprit_point++;
				attack_point++;
				speed_point++;
				space_point += 4;
				if (level % 2 == 0) {
					// 每2级增加1点天赋
					space_gift_point++;
				}
				curBlood = getTotalBlood();
				curSprit = getTotalSprit();
				upLevel = true;
				// TODO:是否触发任务

				// 升级提示
				for (MmochatLevelHint hint : MmochatMainService.levelHints) {
					if (hint.getLevel() == level) {
						String msg = hint.getHint();
						MmochatFriendService.sendMsgToPersonByFriendMessage(
								this, MmochatUtil.wrapColor(msg, Color.yellow));

					}
				}

				// 更新NPC任务标志(所有接任务等级刚好为当前等级的任务)
				Mmochat_4_14S npcPack = new Mmochat_4_14S();
				npcPack.setMe(this);
				for (MmochatTask t : MmochatTaskService.tasks.values()) {
					if (t.getAccept_minLevel() == level) {
						MmochatNpc acceptNpc = MmochatNpcService.getNpcById(t
								.getAccept_npcId());
						if (acceptNpc != null) {
							if (acceptNpc.getMapId() == getMapId()) {
								npcPack.addNpc(acceptNpc);
							}
						}
					}
				}
				if (npcPack.hasNpc()) {
					MmochatUtil.sendCommonPack(this, npcPack);
				}

				// 升到8级打开显示所有人
				if (level == 8) {
					setShowRoleSet(MmochatShowRoleSet.显示所有人);
					Mmochat_1_20S pack = new Mmochat_1_20S();
					pack.setShowRoleSetValue(MmochatShowRoleSet.显示所有人
							.getValue());
					MmochatUtil.sendCommonPack(this, pack);
				}
			}
		}
		// 游客升到6级提示注册
		if (isGuest() && level >= 6) {
			// 提示注册，此时可能还在战斗中...
			Mmochat_1_32S pack = new Mmochat_1_32S();
			MmochatUtil.sendCommonPack(this, pack);

		}

		return upLevel;
	}

	public int getMapId() {
		return mapId;
	}

	public void setMapId(int mapId) {
		this.mapId = mapId;
	}

	public int getX() {
		return x;
	}

	public void setX(int x) {
		this.x = x;
	}

	public int getY() {
		return y;
	}

	public void setY(int y) {
		this.y = y;
	}

	public void setLastActionTime() {
		if (microNetFlowMode) {
			microNetFlowMode = false;
			MmochatChatService.sendSystemMsgToPerson(this, "您已退出休眠模式!");
		}
		lastActionTime.set(System.currentTimeMillis());
	}

	public boolean canReceiveMotionInfo() {
		if (isInBattle() || isInWatchingBattle()) {
			return false;
		}
		if (System.currentTimeMillis() - lastTimeOfReceiveMotionData < MmochatConstant.minIntervalToReceiveSceenInfo) {
			return false;
		}
		return true;
	}

	public AtomicLong getLastActionTime() {
		return lastActionTime;
	}

	public AtomicLong getLatestAutoAddBloodSpritTime() {
		return latestAutoAddBloodSpritTime;
	}

	public void setLatestAutoAddBloodSpritTime(
			AtomicLong latestAutoAddBloodSpritTime) {
		this.latestAutoAddBloodSpritTime = latestAutoAddBloodSpritTime;
	}

	public void setLatestAutoAddBloodSpritTime() {
		latestAutoAddBloodSpritTime.set(System.currentTimeMillis());
	}

	public boolean canAutoUseDrug() {
		if (isInBattle()) {
			return false;
		}
		if (System.currentTimeMillis() - latestAutoAddBloodSpritTime.get() >= MmochatConstant.minIntervalToAutoUseDrug) {
			return true;
		}
		return false;
	}

	public int getLine() {
		return line;
	}

	public void setLine(int line) {
		this.line = line;
	}

	public Map<Integer, Long> getSceenRoles() {
		return sceenRoles;
	}

	public void setSceenRoles(Map<Integer, Long> sceenRoles) {
		this.sceenRoles = new ConcurrentHashMap<Integer, Long>(sceenRoles);
	}

	public void addSceenRole(int roleId, long stateValue) {
		sceenRoles.put(roleId, stateValue);
	}

	public void delSceenRole(int roleId) {
		sceenRoles.remove(roleId);
	}

	public MmochatRoleType getRoleType() {
		return roleType;
	}

	public void setRoleType(MmochatRoleType roleType) {
		this.roleType = roleType;
	}

	public int getBattleId() {
		return battleId;
	}

	public void setBattleId(int battleId) {
		this.battleId = battleId;
	}

	public void leaveBattle() {
		battleId = 0;
		sme.clear();
	}

	public boolean isInBattle() {
		return battleId != 0;
	}

	// 可否进行切磋
	public boolean canFriendlyFight() {
		if (isInBattle()) {
			return false;
		}
		if (isInDeal()) {
			return false;
		}
		if (!acceptFriendlyPk) {
			return false;
		}
		if (!canEnterBattle) {
			return false;
		}
		return true;
	}

	// 可否进行观战
	public boolean canWatchPk() {
		if (isInBattle()) {
			return false;
		}
		if (isInDeal()) {
			return false;
		}
		return true;
	}

	public int getCurBlood() {
		return curBlood;
	}

	public void setCurBlood(int curBlood) {
		this.curBlood = curBlood;
	}

	public void addCurBlood(int addBlood) {
		curBlood += addBlood;
		if (curBlood < 0) {
			curBlood = 0;
		} else if (curBlood > getTotalBlood()) {
			curBlood = getTotalBlood();
		}
	}

	public int getCurSprit() {
		return curSprit;
	}

	public void setCurSprit(int curSprit) {
		this.curSprit = curSprit;
	}

	public void addCurSprit(int addSprit) {
		curSprit += addSprit;
		if (curSprit < 0) {
			curSprit = 0;
		} else if (curSprit > getTotalSprit()) {
			curSprit = getTotalSprit();
		}
	}

	public int getCurPkBlood() {
		return curPkBlood;
	}

	public void setCurPkBlood(int curPkBlood) {
		this.curPkBlood = curPkBlood;
	}

	public boolean isUseDefendInPk() {
		return useDefendInPk;
	}

	public void setUseDefendInPk(boolean useDefendInPk) {
		this.useDefendInPk = useDefendInPk;
	}

	public int getCurPkSprit() {
		return curPkSprit;
	}

	public void setCurPkSprit(int curPkSprit) {
		this.curPkSprit = curPkSprit;
	}

	// 初始化PK
	public void initPkState(int battleId, boolean initBlood) {
		if (initBlood) {
			setCurPkBlood(getTotalBlood());
			setCurPkSprit(getTotalSprit());
		} else {
			setCurPkBlood(Math.min(getTotalBlood(), getCurBlood()));
			setCurPkSprit(Math.min(getTotalSprit(), getCurSprit()));
		}
		setBattleId(battleId);
		sme.clear();
		battleOrders.clear();
		resetCurRoleBmpType();
	}

	// 获取装备附加属性标志
	public int getExtraPointTag() {
		int extraTag = 0;
		for (MmochatEquipPlaceType place : MmochatEquipPlaceType.values()) {
			MmochatPackageGrid grid = myPackage.get(place.getValue());
			if (grid != null && grid.getObject() != null) {
				MmochatCommonObject equip = grid.getObject();
				if (equip.getEquipAttrValue(MmochatEquipAttributeType.力量) > 0) {
					extraTag |= 1;
				}
				if (equip.getEquipAttrValue(MmochatEquipAttributeType.灵力) > 0) {
					extraTag |= 2;
				}
				if (equip.getEquipAttrValue(MmochatEquipAttributeType.体质) > 0) {
					extraTag |= 4;
				}
				if (equip.getEquipAttrValue(MmochatEquipAttributeType.敏捷) > 0) {
					extraTag |= 8;
				}
				if (equip.getEquipAttrValue(MmochatEquipAttributeType.全属性) > 0) {
					extraTag |= 15;
				}
				if (equip.getEquipAttrValue(MmochatEquipAttributeType.野蛮) > 0) {
					extraTag |= 16;
				}
				if (equip.getEquipAttrValue(MmochatEquipAttributeType.智慧) > 0) {
					extraTag |= 32;
				}
				if (equip.getEquipAttrValue(MmochatEquipAttributeType.活力) > 0) {
					extraTag |= 64;
				}
				if (equip.getEquipAttrValue(MmochatEquipAttributeType.坚韧) > 0) {
					extraTag |= 128;
				}
				if (equip.getEquipAttrValue(MmochatEquipAttributeType.灵巧) > 0) {
					extraTag |= 256;
				}
				if (equip.getEquipAttrValue(MmochatEquipAttributeType.全天赋) > 0) {
					extraTag |= 496;
				}
			}
		}
		MmochatChenHao chenhao = getCurChenHao();
		if (chenhao != null) {
			if (chenhao.getEquipAttrValue(MmochatEquipAttributeType.力量) > 0) {
				extraTag |= 1;
			}
			if (chenhao.getEquipAttrValue(MmochatEquipAttributeType.灵力) > 0) {
				extraTag |= 2;
			}
			if (chenhao.getEquipAttrValue(MmochatEquipAttributeType.体质) > 0) {
				extraTag |= 4;
			}
			if (chenhao.getEquipAttrValue(MmochatEquipAttributeType.敏捷) > 0) {
				extraTag |= 8;
			}
			if (chenhao.getEquipAttrValue(MmochatEquipAttributeType.全属性) > 0) {
				extraTag |= 15;
			}
			if (chenhao.getEquipAttrValue(MmochatEquipAttributeType.野蛮) > 0) {
				extraTag |= 16;
			}
			if (chenhao.getEquipAttrValue(MmochatEquipAttributeType.智慧) > 0) {
				extraTag |= 32;
			}
			if (chenhao.getEquipAttrValue(MmochatEquipAttributeType.活力) > 0) {
				extraTag |= 64;
			}
			if (chenhao.getEquipAttrValue(MmochatEquipAttributeType.坚韧) > 0) {
				extraTag |= 128;
			}
			if (chenhao.getEquipAttrValue(MmochatEquipAttributeType.灵巧) > 0) {
				extraTag |= 256;
			}
			if (chenhao.getEquipAttrValue(MmochatEquipAttributeType.全天赋) > 0) {
				extraTag |= 496;
			}
		}

		// 强化丹效果
		{
			if (MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.力量) > 0) {
				extraTag |= 1;
			}
			if (MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.灵力) > 0) {
				extraTag |= 2;
			}
			if (MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.体质) > 0) {
				extraTag |= 4;
			}
			if (MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.敏捷) > 0) {
				extraTag |= 8;
			}
			if (MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.全属性) > 0) {
				extraTag |= 15;
			}
			if (MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.野蛮) > 0) {
				extraTag |= 16;
			}
			if (MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.智慧) > 0) {
				extraTag |= 32;
			}
			if (MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.活力) > 0) {
				extraTag |= 64;
			}
			if (MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.坚韧) > 0) {
				extraTag |= 128;
			}
			if (MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.灵巧) > 0) {
				extraTag |= 256;
			}
			if (MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.全天赋) > 0) {
				extraTag |= 496;
			}
		}

		if (hasPropEffect(MmochatPropType.本月首次充值增加全属.getEffectKey())
				&& MmochatConstant.attrValueForFirstPayThisMonth > 0) {
			extraTag |= 15;
			extraTag |= 496;
		}

		if (isVip()) {
			extraTag |= 15;
		}

		return extraTag;
	}

	// 获取总体质点数
	public int getTotalBloodPoint() {
		int equipBloodPoint = 0;// 装备附加体质点
		for (MmochatEquipPlaceType place : MmochatEquipPlaceType.values()) {
			MmochatPackageGrid grid = myPackage.get(place.getValue());
			if (grid != null && grid.getObject() != null) {
				MmochatCommonObject equip = grid.getObject();
				equipBloodPoint += equip
						.getEquipAttrValue(MmochatEquipAttributeType.体质);
				equipBloodPoint += equip
						.getEquipAttrValue(MmochatEquipAttributeType.全属性);
			}
		}
		// 称号附加属性
		MmochatChenHao chenhao = getCurChenHao();
		if (chenhao != null) {
			equipBloodPoint += chenhao
					.getEquipAttrValue(MmochatEquipAttributeType.体质);
			equipBloodPoint += chenhao
					.getEquipAttrValue(MmochatEquipAttributeType.全属性);
		}
		// 强化丹效果
		{
			equipBloodPoint += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.体质);
			equipBloodPoint += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.全属性);
		}

		// 其它效果
		if (hasPropEffect(MmochatPropType.本月首次充值增加全属.getEffectKey())) {
			equipBloodPoint += MmochatConstant.attrValueForFirstPayThisMonth;
		}

		if (isVip()) {
			equipBloodPoint += MmochatConstant.attrValueForVip;
		}

		int bloodPointNum = blood_point + equipBloodPoint;
		return bloodPointNum;
	}

	// 获取当前总血量:气血 = (100 + 50*等级 + 24*体质*(1+活力*0.03) + 装备"气血")*(1+气血加成/100)
	public int getTotalBlood() {
		int bloodPointNum = blood_point;
		int bloodGiftPointNum = blood_gift_point;
		int equipBlood = 0;
		int equipBloodPercent = 0;
		for (MmochatEquipPlaceType place : MmochatEquipPlaceType.values()) {
			MmochatPackageGrid grid = myPackage.get(place.getValue());
			if (grid != null && grid.getObject() != null) {
				MmochatCommonObject equip = grid.getObject();
				if (equip != null) {
					bloodPointNum += equip
							.getEquipAttrValue(MmochatEquipAttributeType.体质);
					bloodPointNum += equip
							.getEquipAttrValue(MmochatEquipAttributeType.全属性);
					bloodGiftPointNum += equip
							.getEquipAttrValue(MmochatEquipAttributeType.活力);
					bloodGiftPointNum += equip
							.getEquipAttrValue(MmochatEquipAttributeType.全天赋);
					equipBlood += equip
							.getEquipAttrValue(MmochatEquipAttributeType.气血);
					equipBloodPercent += equip
							.getEquipAttrValue(MmochatEquipAttributeType.气血加成);
				}
			}
		}

		// 称号附加属性
		MmochatChenHao chenhao = getCurChenHao();
		if (chenhao != null) {
			bloodPointNum += chenhao
					.getEquipAttrValue(MmochatEquipAttributeType.体质);
			bloodPointNum += chenhao
					.getEquipAttrValue(MmochatEquipAttributeType.全属性);
			bloodGiftPointNum += chenhao
					.getEquipAttrValue(MmochatEquipAttributeType.活力);
			bloodGiftPointNum += chenhao
					.getEquipAttrValue(MmochatEquipAttributeType.全天赋);
			equipBlood += chenhao
					.getEquipAttrValue(MmochatEquipAttributeType.气血);
			equipBloodPercent += chenhao
					.getEquipAttrValue(MmochatEquipAttributeType.气血加成);
		}

		// 强化丹效果
		{
			bloodPointNum += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.体质);
			bloodPointNum += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.全属性);
			bloodGiftPointNum += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.活力);
			bloodGiftPointNum += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.全天赋);
			equipBlood += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.气血);
			equipBloodPercent += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.气血加成);
		}

		// 其它效果
		if (hasPropEffect(MmochatPropType.本月首次充值增加全属.getEffectKey())) {
			bloodPointNum += MmochatConstant.attrValueForFirstPayThisMonth;
			bloodGiftPointNum += MmochatConstant.giftValueForFirstPayThisMonth;
		}

		if (isVip()) {
			bloodPointNum += MmochatConstant.attrValueForVip;
		}

		double totalBlood = (100 + 50 * level + 24 * bloodPointNum
				* (1 + bloodGiftPointNum * 0.03) + equipBlood)
				* (1 + equipBloodPercent / 100.0);

		// 夫妻称号加血10%
		if (chenhao != null
				&& (chenhao.getType() == MmochatChenHaoType.娘子 || chenhao
						.getType() == MmochatChenHaoType.相公)) {
			if (isInTeam()) {
				MmochatTeam team = MmochatTeamService.teams.get(teamId);
				if (team != null) {
					for (Integer roleId : team.getMemberId().values()) {
						if (roleId == wife_roleId) {
							totalBlood = totalBlood * 1.1;
							break;
						}
					}
				}
			}
		}

		// 帮派技能效果
		MmochatGangSkill skill = gangSkills.get(MmochatGangSkillType.日月精华);
		if (skill != null) {
			int percent = MmochatGangSkillType.日月精华
					.getGangSkillEffectPercent(skill.getLevel());
			totalBlood *= (100.0 + percent) / 100.0;
		}

		return (int) totalBlood;
	}

	// 获取当前总法力:法力 = (50 + 20*等级 + 20*灵力 + 装备"法力")*(1+法力加成/100.0)
	public int getTotalSprit() {
		int spritPointNum = sprit_point;
		int equipSprit = 0;
		int equipSpritPercent = 0;
		for (MmochatEquipPlaceType place : MmochatEquipPlaceType.values()) {
			MmochatPackageGrid grid = myPackage.get(place.getValue());
			if (grid != null && grid.getObject() != null) {
				MmochatCommonObject equip = grid.getObject();
				if (equip != null) {
					spritPointNum += equip
							.getEquipAttrValue(MmochatEquipAttributeType.灵力);
					spritPointNum += equip
							.getEquipAttrValue(MmochatEquipAttributeType.全属性);
					equipSprit += equip
							.getEquipAttrValue(MmochatEquipAttributeType.法力);
					equipSpritPercent += equip
							.getEquipAttrValue(MmochatEquipAttributeType.法力加成);
				}
			}
		}
		// 称号附加属性
		MmochatChenHao equip = getCurChenHao();
		if (equip != null) {
			spritPointNum += equip
					.getEquipAttrValue(MmochatEquipAttributeType.灵力);
			spritPointNum += equip
					.getEquipAttrValue(MmochatEquipAttributeType.全属性);
			equipSprit += equip.getEquipAttrValue(MmochatEquipAttributeType.法力);
			equipSpritPercent += equip
					.getEquipAttrValue(MmochatEquipAttributeType.法力加成);
		}
		// 强化丹效果
		{
			spritPointNum += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.灵力);
			spritPointNum += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.全属性);
			equipSprit += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.法力);
			equipSpritPercent += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.法力加成);
		}

		// 其它效果
		if (hasPropEffect(MmochatPropType.本月首次充值增加全属.getEffectKey())) {
			spritPointNum += MmochatConstant.attrValueForFirstPayThisMonth;
		}

		if (isVip()) {
			spritPointNum += MmochatConstant.attrValueForVip;
		}

		return (int) ((50 + 20 * level + 20 * spritPointNum + equipSprit) * (1 + equipSpritPercent / 100.0));
	}

	// 获取当前总力量点数
	public int getTotalAttackPoint() {
		int equipAttackPoint = 0;// 装备附加力量点
		for (MmochatEquipPlaceType place : MmochatEquipPlaceType.values()) {
			MmochatPackageGrid grid = myPackage.get(place.getValue());
			if (grid != null && grid.getObject() != null) {
				MmochatCommonObject equip = grid.getObject();
				if (equip != null) {
					equipAttackPoint += equip
							.getEquipAttrValue(MmochatEquipAttributeType.力量);
					equipAttackPoint += equip
							.getEquipAttrValue(MmochatEquipAttributeType.全属性);
				}
			}
		}
		// 称号附加属性
		MmochatChenHao equip = getCurChenHao();
		if (equip != null) {
			equipAttackPoint += equip
					.getEquipAttrValue(MmochatEquipAttributeType.力量);
			equipAttackPoint += equip
					.getEquipAttrValue(MmochatEquipAttributeType.全属性);
		}
		// 强化丹效果
		{
			equipAttackPoint += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.力量);
			equipAttackPoint += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.全属性);
		}
		// 其它效果
		if (hasPropEffect(MmochatPropType.本月首次充值增加全属.getEffectKey())) {
			equipAttackPoint += MmochatConstant.attrValueForFirstPayThisMonth;
		}

		if (isVip()) {
			equipAttackPoint += MmochatConstant.attrValueForVip;
		}

		int attackPointNum = attack_point + equipAttackPoint;
		return attackPointNum;
	}

	// 获取当前物理伤害
	public int getPhysicalAttack() {
		return (int) getPhysicalAttackValue();
	}

	// 获取当前物理伤害
	// 物伤 = [100 + 10*等级 + 15*力量*(1+野蛮*0.03) + 装备"伤害" + 装备"物伤"] * [1 +
	// 装备"物伤加成"/100.0]
	public double getPhysicalAttackValue() {
		int attackPoint = getTotalAttackPoint();
		int attackGiftPoint = attack_gift_point;
		int equipAttack = 0;
		int equipPhysicalAttack = 0;
		int equipAttackPercent = 0;

		for (MmochatEquipPlaceType place : MmochatEquipPlaceType.values()) {
			MmochatPackageGrid grid = myPackage.get(place.getValue());
			if (grid != null && grid.getObject() != null) {
				MmochatCommonObject equip = grid.getObject();
				if (equip != null) {
					attackGiftPoint += equip
							.getEquipAttrValue(MmochatEquipAttributeType.野蛮);
					attackGiftPoint += equip
							.getEquipAttrValue(MmochatEquipAttributeType.全天赋);
					equipAttack += equip
							.getEquipAttrValue(MmochatEquipAttributeType.伤害);
					equipPhysicalAttack += equip
							.getEquipAttrValue(MmochatEquipAttributeType.物伤);
					equipAttackPercent += equip
							.getEquipAttrValue(MmochatEquipAttributeType.物伤加成);
				}
			}
		}
		// 称号附加属性
		MmochatChenHao equip = getCurChenHao();
		if (equip != null) {
			attackGiftPoint += equip
					.getEquipAttrValue(MmochatEquipAttributeType.野蛮);
			attackGiftPoint += equip
					.getEquipAttrValue(MmochatEquipAttributeType.全天赋);
			equipAttack += equip
					.getEquipAttrValue(MmochatEquipAttributeType.伤害);
			equipPhysicalAttack += equip
					.getEquipAttrValue(MmochatEquipAttributeType.物伤);
			equipAttackPercent += equip
					.getEquipAttrValue(MmochatEquipAttributeType.物伤加成);
		}
		// 强化丹效果
		{
			attackGiftPoint += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.野蛮);
			attackGiftPoint += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.全天赋);
			equipAttack += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.伤害);
			equipPhysicalAttack += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.物伤);
			equipAttackPercent += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.物伤加成);
		}
		// 其它效果
		if (hasPropEffect(MmochatPropType.本月首次充值增加全属.getEffectKey())) {
			attackGiftPoint += MmochatConstant.giftValueForFirstPayThisMonth;
		}

		double attack = (100 + 10 * level + 15 * attackPoint
				* (1 + attackGiftPoint * 0.03) + equipAttack + equipPhysicalAttack)
				* (1 + equipAttackPercent / 100.0);

		// 帮派技能效果
		MmochatGangSkill skill = gangSkills.get(MmochatGangSkillType.天生神力);
		if (skill != null) {
			int percent = MmochatGangSkillType.天生神力
					.getGangSkillEffectPercent(skill.getLevel());
			attack *= (100.0 + percent) / 100.0;
		}

		// 辅助技能效果
		double addPercent = 0;
		MmochatSme attackSme = sme.get(MmochatSmeType.加攻辅助);
		if (attackSme != null && attackSme.getKeepRound() > 0) {
			addPercent += attackSme.getValue();
		}
		attack = attack * (100 + addPercent) / 100;

		return attack;
	}

	// 获取总野蛮天赋点
	public int getTotalAttack_gift_point() {
		int attackGiftPoint = attack_gift_point;

		for (MmochatEquipPlaceType place : MmochatEquipPlaceType.values()) {
			MmochatPackageGrid grid = myPackage.get(place.getValue());
			if (grid != null && grid.getObject() != null) {
				MmochatCommonObject equip = grid.getObject();
				if (equip != null) {
					attackGiftPoint += equip
							.getEquipAttrValue(MmochatEquipAttributeType.野蛮);
					attackGiftPoint += equip
							.getEquipAttrValue(MmochatEquipAttributeType.全天赋);
				}
			}
		}
		// 称号附加属性
		MmochatChenHao equip = getCurChenHao();
		if (equip != null) {
			attackGiftPoint += equip
					.getEquipAttrValue(MmochatEquipAttributeType.野蛮);
			attackGiftPoint += equip
					.getEquipAttrValue(MmochatEquipAttributeType.全天赋);
		}
		// 强化丹效果
		{
			attackGiftPoint += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.野蛮);
			attackGiftPoint += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.全天赋);
		}
		// 其它效果
		if (hasPropEffect(MmochatPropType.本月首次充值增加全属.getEffectKey())) {
			attackGiftPoint += MmochatConstant.giftValueForFirstPayThisMonth;
		}

		return attackGiftPoint;
	}

	// 获取当前总灵力点数
	public int getTotalSpritPoint() {
		int equipSpritPoint = 0;// 装备附加灵力点
		for (MmochatEquipPlaceType place : MmochatEquipPlaceType.values()) {
			MmochatPackageGrid grid = myPackage.get(place.getValue());
			if (grid != null && grid.getObject() != null) {
				MmochatCommonObject equip = grid.getObject();
				if (equip != null) {
					equipSpritPoint += equip
							.getEquipAttrValue(MmochatEquipAttributeType.灵力);
					equipSpritPoint += equip
							.getEquipAttrValue(MmochatEquipAttributeType.全属性);
				}
			}
		}
		// 称号附加属性
		MmochatChenHao equip = getCurChenHao();
		if (equip != null) {
			equipSpritPoint += equip
					.getEquipAttrValue(MmochatEquipAttributeType.灵力);
			equipSpritPoint += equip
					.getEquipAttrValue(MmochatEquipAttributeType.全属性);
		}
		// 强化丹效果
		{
			equipSpritPoint += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.灵力);
			equipSpritPoint += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.全属性);
		}
		// 其它效果
		if (hasPropEffect(MmochatPropType.本月首次充值增加全属.getEffectKey())) {
			equipSpritPoint += MmochatConstant.attrValueForFirstPayThisMonth;
		}

		if (isVip()) {
			equipSpritPoint += MmochatConstant.attrValueForVip;
		}

		int spritPointNum = sprit_point + equipSpritPoint;
		return spritPointNum;
	}

	// 获取当前法术伤害
	public int getSpritAttack() {
		return (int) getSpritAttackValue();
	}

	// 获取当前法术伤害:[100 + 10*等级 + 15*灵力*(1+智慧*0.03) + 装备"伤害" + 装备"法伤"] * [1 +
	// 装备"法伤加成"/100.0]
	public double getSpritAttackValue() {
		int spritPointNum = getTotalSpritPoint();
		int spritGiftPoint = sprit_gift_point;
		int equipAttack = 0;
		int equipMagicAttack = 0;
		int equipMttackPercent = 0;

		for (MmochatEquipPlaceType place : MmochatEquipPlaceType.values()) {
			MmochatPackageGrid grid = myPackage.get(place.getValue());
			if (grid != null && grid.getObject() != null) {
				MmochatCommonObject equip = grid.getObject();
				if (equip != null) {
					spritGiftPoint += equip
							.getEquipAttrValue(MmochatEquipAttributeType.智慧);
					spritGiftPoint += equip
							.getEquipAttrValue(MmochatEquipAttributeType.全天赋);
					equipAttack += equip
							.getEquipAttrValue(MmochatEquipAttributeType.伤害);
					equipMagicAttack += equip
							.getEquipAttrValue(MmochatEquipAttributeType.法伤);
					equipMttackPercent += equip
							.getEquipAttrValue(MmochatEquipAttributeType.法伤加成);
					switch (family) {
					case 阐教:
						equipMttackPercent += equip
								.getEquipAttrValue(MmochatEquipAttributeType.雷系法攻加成);
						break;
					case 人教:
						equipMttackPercent += equip
								.getEquipAttrValue(MmochatEquipAttributeType.水系法攻加成);
						break;
					case 截教:
						equipMttackPercent += equip
								.getEquipAttrValue(MmochatEquipAttributeType.毒系法攻加成);
						break;
					default:
						break;
					}
				}
			}
		}
		// 称号附加属性
		MmochatChenHao equip = getCurChenHao();
		if (equip != null) {
			spritGiftPoint += equip
					.getEquipAttrValue(MmochatEquipAttributeType.智慧);
			spritGiftPoint += equip
					.getEquipAttrValue(MmochatEquipAttributeType.全天赋);
			equipAttack += equip
					.getEquipAttrValue(MmochatEquipAttributeType.伤害);
			equipMagicAttack += equip
					.getEquipAttrValue(MmochatEquipAttributeType.法伤);
			equipMttackPercent += equip
					.getEquipAttrValue(MmochatEquipAttributeType.法伤加成);
			switch (family) {
			case 阐教:
				equipMttackPercent += equip
						.getEquipAttrValue(MmochatEquipAttributeType.雷系法攻加成);
				break;
			case 人教:
				equipMttackPercent += equip
						.getEquipAttrValue(MmochatEquipAttributeType.水系法攻加成);
				break;
			case 截教:
				equipMttackPercent += equip
						.getEquipAttrValue(MmochatEquipAttributeType.毒系法攻加成);
				break;
			default:
				break;
			}
		}
		// 强化丹效果
		{
			spritGiftPoint += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.智慧);
			spritGiftPoint += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.全天赋);
			equipAttack += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.伤害);
			equipMagicAttack += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.法伤);
			equipMttackPercent += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.法伤加成);
			switch (family) {
			case 阐教:
				equipMttackPercent += MmochatStrengthDrug.getEquipAttrValue(
						this, MmochatEquipAttributeType.雷系法攻加成);
				break;
			case 人教:
				equipMttackPercent += MmochatStrengthDrug.getEquipAttrValue(
						this, MmochatEquipAttributeType.水系法攻加成);
				break;
			case 截教:
				equipMttackPercent += MmochatStrengthDrug.getEquipAttrValue(
						this, MmochatEquipAttributeType.毒系法攻加成);
				break;
			default:
				break;
			}
		}
		// 其它效果
		if (hasPropEffect(MmochatPropType.本月首次充值增加全属.getEffectKey())) {
			spritGiftPoint += MmochatConstant.giftValueForFirstPayThisMonth;
		}

		double attack = (100 + 10 * level + 15 * spritPointNum
				* (1 + spritGiftPoint * 0.03) + equipAttack + equipMagicAttack)
				* (1 + equipMttackPercent / 100.0);

		// 帮派技能效果
		MmochatGangSkill skill = gangSkills.get(MmochatGangSkillType.万灵遮天);
		if (skill != null) {
			int percent = MmochatGangSkillType.万灵遮天
					.getGangSkillEffectPercent(skill.getLevel());
			attack *= (100.0 + percent) / 100.0;
		}

		// 辅助技能效果
		double addPercent = 0;
		MmochatSme attackSme = sme.get(MmochatSmeType.加攻辅助);
		if (attackSme != null && attackSme.getKeepRound() > 0) {
			addPercent += attackSme.getValue();
		}
		attack = attack * (100 + addPercent) / 100;

		return attack;
	}

	// 获取总智慧天赋点
	public int getTotalSprit_gift_point() {
		int spritGiftPoint = sprit_gift_point;

		for (MmochatEquipPlaceType place : MmochatEquipPlaceType.values()) {
			MmochatPackageGrid grid = myPackage.get(place.getValue());
			if (grid != null && grid.getObject() != null) {
				MmochatCommonObject equip = grid.getObject();
				if (equip != null) {
					spritGiftPoint += equip
							.getEquipAttrValue(MmochatEquipAttributeType.智慧);
					spritGiftPoint += equip
							.getEquipAttrValue(MmochatEquipAttributeType.全天赋);
				}
			}
		}
		// 称号附加属性
		MmochatChenHao equip = getCurChenHao();
		if (equip != null) {
			spritGiftPoint += equip
					.getEquipAttrValue(MmochatEquipAttributeType.智慧);
			spritGiftPoint += equip
					.getEquipAttrValue(MmochatEquipAttributeType.全天赋);
		}
		// 强化丹效果
		{
			spritGiftPoint += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.智慧);
			spritGiftPoint += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.全天赋);
		}
		// 其它效果
		if (hasPropEffect(MmochatPropType.本月首次充值增加全属.getEffectKey())) {
			spritGiftPoint += MmochatConstant.giftValueForFirstPayThisMonth;
		}

		return spritGiftPoint;
	}

	// 获取当前总敏捷点数
	public int getTotalSpeedPoint() {
		int equipSpeedPoint = 0;// 装备附加敏捷点
		for (MmochatEquipPlaceType place : MmochatEquipPlaceType.values()) {
			MmochatPackageGrid grid = myPackage.get(place.getValue());
			if (grid != null && grid.getObject() != null) {
				MmochatCommonObject equip = grid.getObject();
				if (equip != null) {
					equipSpeedPoint += equip
							.getEquipAttrValue(MmochatEquipAttributeType.敏捷);
					equipSpeedPoint += equip
							.getEquipAttrValue(MmochatEquipAttributeType.全属性);
				}
			}
		}
		// 称号附加属性
		MmochatChenHao equip = getCurChenHao();
		if (equip != null) {
			equipSpeedPoint += equip
					.getEquipAttrValue(MmochatEquipAttributeType.敏捷);
			equipSpeedPoint += equip
					.getEquipAttrValue(MmochatEquipAttributeType.全属性);
		}
		// 强化丹效果
		{
			equipSpeedPoint += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.敏捷);
			equipSpeedPoint += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.全属性);
		}
		// 其它效果
		if (hasPropEffect(MmochatPropType.本月首次充值增加全属.getEffectKey())) {
			equipSpeedPoint += MmochatConstant.attrValueForFirstPayThisMonth;
		}
		if (isVip()) {
			equipSpeedPoint += MmochatConstant.attrValueForVip;
		}

		int speedPointNum = speed_point + equipSpeedPoint;
		return speedPointNum;
	}

	// 获取当前速度:(100 + 5*等级 + 5*敏捷*(1+灵巧*0.03) + 装备"速度")*(1+速度加成/100.0)
	public int getSpeed() {
		int speedPoint = getTotalSpeedPoint();
		int speedGiftPoint = speed_gift_point;
		int equipSpeed = 0;
		int equipSpeedPercent = 0;
		for (MmochatEquipPlaceType place : MmochatEquipPlaceType.values()) {
			MmochatPackageGrid grid = myPackage.get(place.getValue());
			if (grid != null && grid.getObject() != null) {
				MmochatCommonObject equip = grid.getObject();
				if (equip != null) {
					speedGiftPoint += equip
							.getEquipAttrValue(MmochatEquipAttributeType.灵巧);
					speedGiftPoint += equip
							.getEquipAttrValue(MmochatEquipAttributeType.全天赋);
					equipSpeed += equip
							.getEquipAttrValue(MmochatEquipAttributeType.速度);
					equipSpeedPercent += equip
							.getEquipAttrValue(MmochatEquipAttributeType.速度加成);
				}
			}
		}
		// 称号附加属性
		MmochatChenHao equip = getCurChenHao();
		if (equip != null) {
			speedGiftPoint += equip
					.getEquipAttrValue(MmochatEquipAttributeType.灵巧);
			speedGiftPoint += equip
					.getEquipAttrValue(MmochatEquipAttributeType.全天赋);
			equipSpeed += equip.getEquipAttrValue(MmochatEquipAttributeType.速度);
			equipSpeedPercent += equip
					.getEquipAttrValue(MmochatEquipAttributeType.速度加成);
		}
		// 强化丹效果
		{
			speedGiftPoint += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.灵巧);
			speedGiftPoint += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.全天赋);
			equipSpeed += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.速度);
			equipSpeedPercent += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.速度加成);
		}
		// 其它效果
		if (hasPropEffect(MmochatPropType.本月首次充值增加全属.getEffectKey())) {
			speedGiftPoint += MmochatConstant.giftValueForFirstPayThisMonth;
		}

		double speed = (100 + 5 * level + 5 * speedPoint
				* (1 + speedGiftPoint * 0.03) + equipSpeed)
				* (1 + equipSpeedPercent / 100.0);
		// 辅助技能效果
		double addPercent = 0;
		MmochatSme speedSme = sme.get(MmochatSmeType.加速辅助);
		if (speedSme != null && speedSme.getKeepRound() > 0) {
			addPercent += speedSme.getValue();
		}
		speed = speed * (100 + addPercent) / 100;

		return (int) speed;
	}

	// 获取物理闪避:5 + 装备"物理闪避"
	public int getPhysicalAvoid() {
		int equipAvoid = 0; // 装备附加闪避
		for (MmochatEquipPlaceType place : MmochatEquipPlaceType.values()) {
			MmochatPackageGrid grid = myPackage.get(place.getValue());
			if (grid != null && grid.getObject() != null) {
				MmochatCommonObject equip = grid.getObject();
				if (equip != null) {
					equipAvoid += equip
							.getEquipAttrValue(MmochatEquipAttributeType.物理闪避);
				}
			}
		}
		// 称号附加属性
		MmochatChenHao equip = getCurChenHao();
		if (equip != null) {
			equipAvoid += equip
					.getEquipAttrValue(MmochatEquipAttributeType.物理闪避);
		}
		// 强化丹效果
		{
			equipAvoid += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.物理闪避);
		}
		return (int) (5 + equipAvoid);
	}

	// 获取法术闪避:5 + 装备"法术闪避"
	public int getMagicAvoid() {
		int equipAvoid = 0; // 装备附加闪避
		for (MmochatEquipPlaceType place : MmochatEquipPlaceType.values()) {
			MmochatPackageGrid grid = myPackage.get(place.getValue());
			if (grid != null && grid.getObject() != null) {
				MmochatCommonObject equip = grid.getObject();
				if (equip != null) {
					equipAvoid += equip
							.getEquipAttrValue(MmochatEquipAttributeType.法术闪避);
				}
			}
		}
		// 称号附加属性
		MmochatChenHao equip = getCurChenHao();
		if (equip != null) {
			equipAvoid += equip
					.getEquipAttrValue(MmochatEquipAttributeType.法术闪避);
		}
		// 强化丹效果
		{
			equipAvoid += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.法术闪避);
		}
		return (int) (5 + equipAvoid);
	}

	// 获取总灵巧天赋点
	public int getTotalSpeed_gift_point() {
		int speedGiftPoint = speed_gift_point;

		for (MmochatEquipPlaceType place : MmochatEquipPlaceType.values()) {
			MmochatPackageGrid grid = myPackage.get(place.getValue());
			if (grid != null && grid.getObject() != null) {
				MmochatCommonObject equip = grid.getObject();
				if (equip != null) {
					speedGiftPoint += equip
							.getEquipAttrValue(MmochatEquipAttributeType.灵巧);
					speedGiftPoint += equip
							.getEquipAttrValue(MmochatEquipAttributeType.全天赋);
				}
			}
		}
		// 称号附加属性
		MmochatChenHao equip = getCurChenHao();
		if (equip != null) {
			speedGiftPoint += equip
					.getEquipAttrValue(MmochatEquipAttributeType.灵巧);
			speedGiftPoint += equip
					.getEquipAttrValue(MmochatEquipAttributeType.全天赋);
		}
		// 强化丹效果
		{
			speedGiftPoint += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.灵巧);
			speedGiftPoint += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.全天赋);
		}
		// 其它效果
		if (hasPropEffect(MmochatPropType.本月首次充值增加全属.getEffectKey())) {
			speedGiftPoint += MmochatConstant.giftValueForFirstPayThisMonth;
		}

		return speedGiftPoint;
	}

	// 获取物防
	// [50 + 8*等级 + 8*体质*(1+坚韧*0.03) + 装备"防御"] * [1 + 装备"物防加成"/100.0]
	public int getPhysicalDefend() {
		int bloodPoint = getTotalBloodPoint();
		int defendGiftPoint = defend_gift_point;
		int equipDefend = 0;
		int equipDefendPercent = 0;
		for (MmochatEquipPlaceType place : MmochatEquipPlaceType.values()) {
			MmochatPackageGrid grid = myPackage.get(place.getValue());
			if (grid != null && grid.getObject() != null) {
				MmochatCommonObject equip = grid.getObject();
				if (equip != null) {
					defendGiftPoint += equip
							.getEquipAttrValue(MmochatEquipAttributeType.坚韧);
					defendGiftPoint += equip
							.getEquipAttrValue(MmochatEquipAttributeType.全天赋);
					equipDefend += equip
							.getEquipAttrValue(MmochatEquipAttributeType.防御);
					equipDefendPercent += equip
							.getEquipAttrValue(MmochatEquipAttributeType.物防加成);
				}
			}
		}
		// 称号附加属性
		MmochatChenHao equip = getCurChenHao();
		if (equip != null) {
			defendGiftPoint += equip
					.getEquipAttrValue(MmochatEquipAttributeType.坚韧);
			defendGiftPoint += equip
					.getEquipAttrValue(MmochatEquipAttributeType.全天赋);
			equipDefend += equip
					.getEquipAttrValue(MmochatEquipAttributeType.防御);
			equipDefendPercent += equip
					.getEquipAttrValue(MmochatEquipAttributeType.物防加成);
		}
		// 强化丹效果
		{
			defendGiftPoint += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.坚韧);
			defendGiftPoint += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.全天赋);
			equipDefend += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.防御);
			equipDefendPercent += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.物防加成);
		}
		// 其它效果
		if (hasPropEffect(MmochatPropType.本月首次充值增加全属.getEffectKey())) {
			defendGiftPoint += MmochatConstant.giftValueForFirstPayThisMonth;
		}

		double defend = (50 + 8 * level + 8 * bloodPoint
				* (1 + defendGiftPoint * 0.03) + equipDefend)
				* (1 + equipDefendPercent / 100.0);

		// 帮派称号加防
		if (equip != null) {
			int defendAddPercent = 0;
			switch (equip.getType()) {
			case 帮主:
			case 副帮主:
			case 精英:
				defendAddPercent = 2;
				break;
			case 帮众:
				defendAddPercent = 1;
				break;
			default:
				break;
			}
			if (defendAddPercent > 0) {
				if (isInTeam() && hasGang()) {
					MmochatTeam team = MmochatTeamService.teams.get(teamId);
					if (team != null) {
						int num = team.getSameGangMemberNum(gangId) - 1;
						if (num > 0) {
							defend = defend
									* (1 + defendAddPercent * num / 100.0);
						}
					}
				}
			}
		}

		// 帮派技能效果
		MmochatGangSkill skill = gangSkills.get(MmochatGangSkillType.金刚护体);
		if (skill != null) {
			int percent = MmochatGangSkillType.金刚护体
					.getGangSkillEffectPercent(skill.getLevel());
			defend *= (100.0 + percent) / 100.0;
		}

		// 辅助技能效果
		double addPercent = 0;
		MmochatSme attackSme = sme.get(MmochatSmeType.加防辅助);
		if (attackSme != null && attackSme.getKeepRound() > 0) {
			addPercent += attackSme.getValue();
		}
		defend = defend * (100 + addPercent) / 100;

		return (int) defend;
	}

	// 获取法防
	// [50 + 8*等级 + 8*体质*(1+坚韧*0.03) + 装备"防御"] * [1 + 装备"法防加成"/100.0]
	public int getMagicDefend() {
		int bloodPoint = getTotalBloodPoint();
		int defendGiftPoint = defend_gift_point;
		int equipDefend = 0;
		int equipDefendPercent = 0;
		for (MmochatEquipPlaceType place : MmochatEquipPlaceType.values()) {
			MmochatPackageGrid grid = myPackage.get(place.getValue());
			if (grid != null && grid.getObject() != null) {
				MmochatCommonObject equip = grid.getObject();
				if (equip != null) {
					defendGiftPoint += equip
							.getEquipAttrValue(MmochatEquipAttributeType.坚韧);
					defendGiftPoint += equip
							.getEquipAttrValue(MmochatEquipAttributeType.全天赋);
					equipDefend += equip
							.getEquipAttrValue(MmochatEquipAttributeType.防御);
					equipDefendPercent += equip
							.getEquipAttrValue(MmochatEquipAttributeType.法防加成);
				}
			}
		}
		// 称号附加属性
		MmochatChenHao equip = getCurChenHao();
		if (equip != null) {
			defendGiftPoint += equip
					.getEquipAttrValue(MmochatEquipAttributeType.坚韧);
			defendGiftPoint += equip
					.getEquipAttrValue(MmochatEquipAttributeType.全天赋);
			equipDefend += equip
					.getEquipAttrValue(MmochatEquipAttributeType.防御);
			equipDefendPercent += equip
					.getEquipAttrValue(MmochatEquipAttributeType.法防加成);
		}
		// 强化丹效果
		{
			defendGiftPoint += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.坚韧);
			defendGiftPoint += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.全天赋);
			equipDefend += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.防御);
			equipDefendPercent += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.法防加成);
		}
		// 其它效果
		if (hasPropEffect(MmochatPropType.本月首次充值增加全属.getEffectKey())) {
			defendGiftPoint += MmochatConstant.giftValueForFirstPayThisMonth;
		}

		double defend = (50 + 8 * level + 8 * bloodPoint
				* (1 + defendGiftPoint * 0.03) + equipDefend)
				* (1 + equipDefendPercent / 100.0);

		// 帮派称号加防
		if (equip != null) {
			int defendAddPercent = 0;
			switch (equip.getType()) {
			case 帮主:
			case 副帮主:
			case 精英:
				defendAddPercent = 2;
				break;
			case 帮众:
				defendAddPercent = 1;
				break;
			default:
				break;
			}
			if (defendAddPercent > 0) {
				if (isInTeam() && hasGang()) {
					MmochatTeam team = MmochatTeamService.teams.get(teamId);
					if (team != null) {
						int num = team.getSameGangMemberNum(gangId) - 1;
						if (num > 0) {
							defend = defend
									* (1 + defendAddPercent * num / 100.0);
						}
					}
				}
			}
		}

		// 帮派技能效果
		MmochatGangSkill skill = gangSkills.get(MmochatGangSkillType.法灵护体);
		if (skill != null) {
			int percent = MmochatGangSkillType.法灵护体
					.getGangSkillEffectPercent(skill.getLevel());
			defend *= (100.0 + percent) / 100.0;
		}

		// 辅助技能效果
		double addPercent = 0;
		MmochatSme attackSme = sme.get(MmochatSmeType.加防辅助);
		if (attackSme != null && attackSme.getKeepRound() > 0) {
			addPercent += attackSme.getValue();
		}
		defend = defend * (100 + addPercent) / 100;

		return (int) defend;
	}

	// 获取总坚韧天赋点
	public int getTotalDefend_gift_point() {
		int defendGiftPoint = defend_gift_point;

		for (MmochatEquipPlaceType place : MmochatEquipPlaceType.values()) {
			MmochatPackageGrid grid = myPackage.get(place.getValue());
			if (grid != null && grid.getObject() != null) {
				MmochatCommonObject equip = grid.getObject();
				if (equip != null) {
					defendGiftPoint += equip
							.getEquipAttrValue(MmochatEquipAttributeType.坚韧);
					defendGiftPoint += equip
							.getEquipAttrValue(MmochatEquipAttributeType.全天赋);
				}
			}
		}
		// 称号附加属性
		MmochatChenHao equip = getCurChenHao();
		if (equip != null) {
			defendGiftPoint += equip
					.getEquipAttrValue(MmochatEquipAttributeType.坚韧);
			defendGiftPoint += equip
					.getEquipAttrValue(MmochatEquipAttributeType.全天赋);
		}
		// 强化丹效果
		{
			defendGiftPoint += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.坚韧);
			defendGiftPoint += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.全天赋);
		}
		// 其它效果
		if (hasPropEffect(MmochatPropType.本月首次充值增加全属.getEffectKey())) {
			defendGiftPoint += MmochatConstant.giftValueForFirstPayThisMonth;
		}

		return defendGiftPoint;
	}

	// 获取总活力天赋点
	public int getTotalBlood_gift_point() {
		int bloodGiftPoint = blood_gift_point;

		for (MmochatEquipPlaceType place : MmochatEquipPlaceType.values()) {
			MmochatPackageGrid grid = myPackage.get(place.getValue());
			if (grid != null && grid.getObject() != null) {
				MmochatCommonObject equip = grid.getObject();
				if (equip != null) {
					bloodGiftPoint += equip
							.getEquipAttrValue(MmochatEquipAttributeType.活力);
					bloodGiftPoint += equip
							.getEquipAttrValue(MmochatEquipAttributeType.全天赋);
				}
			}
		}
		// 称号附加属性
		MmochatChenHao equip = getCurChenHao();
		if (equip != null) {
			bloodGiftPoint += equip
					.getEquipAttrValue(MmochatEquipAttributeType.活力);
			bloodGiftPoint += equip
					.getEquipAttrValue(MmochatEquipAttributeType.全天赋);
		}
		// 强化丹效果
		{
			bloodGiftPoint += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.活力);
			bloodGiftPoint += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.全天赋);
		}
		// 其它效果
		if (hasPropEffect(MmochatPropType.本月首次充值增加全属.getEffectKey())) {
			bloodGiftPoint += MmochatConstant.giftValueForFirstPayThisMonth;
		}

		return bloodGiftPoint;
	}

	// 获取抗混乱率
	@Override
	public int getAntiConfuse() {
		int equipAnti = 0;
		for (MmochatEquipPlaceType place : MmochatEquipPlaceType.values()) {
			MmochatPackageGrid grid = myPackage.get(place.getValue());
			if (grid != null && grid.getObject() != null) {
				MmochatCommonObject equip = grid.getObject();
				if (equip != null) {
					equipAnti += equip
							.getEquipAttrValue(MmochatEquipAttributeType.混乱抵抗);
					equipAnti += equip
							.getEquipAttrValue(MmochatEquipAttributeType.全异常抵抗);
				}
			}
		}
		// 称号附加属性
		MmochatChenHao equip = getCurChenHao();
		if (equip != null) {
			equipAnti += equip
					.getEquipAttrValue(MmochatEquipAttributeType.混乱抵抗);
			equipAnti += equip
					.getEquipAttrValue(MmochatEquipAttributeType.全异常抵抗);
		}
		// 强化丹效果
		{
			equipAnti += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.混乱抵抗);
			equipAnti += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.全异常抵抗);
		}
		// 帮派技能效果
		MmochatGangSkill skill = gangSkills.get(MmochatGangSkillType.万魔不侵);
		if (skill != null) {
			int percent = MmochatGangSkillType.万魔不侵
					.getGangSkillEffectPercent(skill.getLevel());
			equipAnti += percent;
		}

		return equipAnti;
	}

	// 获取抗冰冻率
	@Override
	public int getAntiFreeze() {
		int equipAnti = 0;
		for (MmochatEquipPlaceType place : MmochatEquipPlaceType.values()) {
			MmochatPackageGrid grid = myPackage.get(place.getValue());
			if (grid != null && grid.getObject() != null) {
				MmochatCommonObject equip = grid.getObject();
				if (equip != null) {
					equipAnti += equip
							.getEquipAttrValue(MmochatEquipAttributeType.冰冻抵抗);
					equipAnti += equip
							.getEquipAttrValue(MmochatEquipAttributeType.全异常抵抗);
				}
			}
		}
		// 称号附加属性
		MmochatChenHao equip = getCurChenHao();
		if (equip != null) {
			equipAnti += equip
					.getEquipAttrValue(MmochatEquipAttributeType.冰冻抵抗);
			equipAnti += equip
					.getEquipAttrValue(MmochatEquipAttributeType.全异常抵抗);
		}
		// 强化丹效果
		{
			equipAnti += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.冰冻抵抗);
			equipAnti += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.全异常抵抗);
		}
		// 帮派技能效果
		MmochatGangSkill skill = gangSkills.get(MmochatGangSkillType.万魔不侵);
		if (skill != null) {
			int percent = MmochatGangSkillType.万魔不侵
					.getGangSkillEffectPercent(skill.getLevel());
			equipAnti += percent;
		}

		return equipAnti;
	}

	// 获取抗封印率
	@Override
	public int getAntiSeal() {
		int equipAnti = 0;
		for (MmochatEquipPlaceType place : MmochatEquipPlaceType.values()) {
			MmochatPackageGrid grid = myPackage.get(place.getValue());
			if (grid != null && grid.getObject() != null) {
				MmochatCommonObject equip = grid.getObject();
				if (equip != null) {
					equipAnti += equip
							.getEquipAttrValue(MmochatEquipAttributeType.封印抵抗);
					equipAnti += equip
							.getEquipAttrValue(MmochatEquipAttributeType.全异常抵抗);
				}
			}
		}
		// 称号附加属性
		MmochatChenHao equip = getCurChenHao();
		if (equip != null) {
			equipAnti += equip
					.getEquipAttrValue(MmochatEquipAttributeType.封印抵抗);
			equipAnti += equip
					.getEquipAttrValue(MmochatEquipAttributeType.全异常抵抗);
		}
		// 强化丹效果
		{
			equipAnti += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.封印抵抗);
			equipAnti += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.全异常抵抗);
		}
		// 帮派技能效果
		MmochatGangSkill skill = gangSkills.get(MmochatGangSkillType.万魔不侵);
		if (skill != null) {
			int percent = MmochatGangSkillType.万魔不侵
					.getGangSkillEffectPercent(skill.getLevel());
			equipAnti += percent;
		}

		return equipAnti;
	}

	// 获取忽视抗混乱率
	@Override
	public int getIgnoreAntiConfuse() {
		int equipValue = 0;
		for (MmochatEquipPlaceType place : MmochatEquipPlaceType.values()) {
			MmochatPackageGrid grid = myPackage.get(place.getValue());
			if (grid != null && grid.getObject() != null) {
				MmochatCommonObject equip = grid.getObject();
				if (equip != null) {
					equipValue += equip
							.getEquipAttrValue(MmochatEquipAttributeType.忽视混乱抵抗);
					equipValue += equip
							.getEquipAttrValue(MmochatEquipAttributeType.忽视全异常抵抗);
				}
			}
		}
		// 称号附加属性
		MmochatChenHao equip = getCurChenHao();
		if (equip != null) {
			equipValue += equip
					.getEquipAttrValue(MmochatEquipAttributeType.忽视混乱抵抗);
			equipValue += equip
					.getEquipAttrValue(MmochatEquipAttributeType.忽视全异常抵抗);
		}
		// 强化丹效果
		{
			equipValue += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.忽视混乱抵抗);
			equipValue += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.忽视全异常抵抗);
		}
		// 帮派技能效果
		MmochatGangSkill skill = gangSkills.get(MmochatGangSkillType.元魂幻化);
		if (skill != null) {
			int percent = MmochatGangSkillType.元魂幻化
					.getGangSkillEffectPercent(skill.getLevel());
			equipValue += percent;
		}

		return equipValue;
	}

	// 获取忽视抗冰冻率
	@Override
	public int getIgnoreAntiFreeze() {
		int equipValue = 0;
		for (MmochatEquipPlaceType place : MmochatEquipPlaceType.values()) {
			MmochatPackageGrid grid = myPackage.get(place.getValue());
			if (grid != null && grid.getObject() != null) {
				MmochatCommonObject equip = grid.getObject();
				if (equip != null) {
					equipValue += equip
							.getEquipAttrValue(MmochatEquipAttributeType.忽视冰冻抵抗);
					equipValue += equip
							.getEquipAttrValue(MmochatEquipAttributeType.忽视全异常抵抗);
				}
			}
		}
		// 称号附加属性
		MmochatChenHao equip = getCurChenHao();
		if (equip != null) {
			equipValue += equip
					.getEquipAttrValue(MmochatEquipAttributeType.忽视冰冻抵抗);
			equipValue += equip
					.getEquipAttrValue(MmochatEquipAttributeType.忽视全异常抵抗);
		}
		// 强化丹效果
		{
			equipValue += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.忽视冰冻抵抗);
			equipValue += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.忽视全异常抵抗);
		}
		// 帮派技能效果
		MmochatGangSkill skill = gangSkills.get(MmochatGangSkillType.元魂幻化);
		if (skill != null) {
			int percent = MmochatGangSkillType.元魂幻化
					.getGangSkillEffectPercent(skill.getLevel());
			equipValue += percent;
		}

		return equipValue;
	}

	// 获取忽视抗封印率
	@Override
	public int getIgnoreAntiSeal() {
		int equipValue = 0;
		for (MmochatEquipPlaceType place : MmochatEquipPlaceType.values()) {
			MmochatPackageGrid grid = myPackage.get(place.getValue());
			if (grid != null && grid.getObject() != null) {
				MmochatCommonObject equip = grid.getObject();
				if (equip != null) {
					equipValue += equip
							.getEquipAttrValue(MmochatEquipAttributeType.忽视封印抵抗);
					equipValue += equip
							.getEquipAttrValue(MmochatEquipAttributeType.忽视全异常抵抗);
				}
			}
		}
		// 称号附加属性
		MmochatChenHao equip = getCurChenHao();
		if (equip != null) {
			equipValue += equip
					.getEquipAttrValue(MmochatEquipAttributeType.忽视封印抵抗);
			equipValue += equip
					.getEquipAttrValue(MmochatEquipAttributeType.忽视全异常抵抗);
		}
		// 强化丹效果
		{
			equipValue += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.忽视封印抵抗);
			equipValue += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.忽视全异常抵抗);
		}
		// 帮派技能效果
		MmochatGangSkill skill = gangSkills.get(MmochatGangSkillType.元魂幻化);
		if (skill != null) {
			int percent = MmochatGangSkillType.元魂幻化
					.getGangSkillEffectPercent(skill.getLevel());
			equipValue += percent;
		}

		return equipValue;
	}

	// 获取法术暴击(1.5倍伤害)
	@Override
	public int getMagicDeadlyAttack() {
		int equipValue = 0;
		for (MmochatEquipPlaceType place : MmochatEquipPlaceType.values()) {
			MmochatPackageGrid grid = myPackage.get(place.getValue());
			if (grid != null && grid.getObject() != null) {
				MmochatCommonObject equip = grid.getObject();
				if (equip != null) {
					equipValue += equip
							.getEquipAttrValue(MmochatEquipAttributeType.法术暴击);
				}
			}
		}
		// 称号附加属性
		MmochatChenHao equip = getCurChenHao();
		if (equip != null) {
			equipValue += equip
					.getEquipAttrValue(MmochatEquipAttributeType.法术暴击);
		}
		// 强化丹效果
		{
			equipValue += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.法术暴击);
		}
		return equipValue;
	}

	// 获取法术暴击抵抗
	@Override
	public int getMagicDeadlyAttackDefend() {
		int equipValue = 0;
		for (MmochatEquipPlaceType place : MmochatEquipPlaceType.values()) {
			MmochatPackageGrid grid = myPackage.get(place.getValue());
			if (grid != null && grid.getObject() != null) {
				MmochatCommonObject equip = grid.getObject();
				if (equip != null) {
					equipValue += equip
							.getEquipAttrValue(MmochatEquipAttributeType.法术暴击抵抗);
				}
			}
		}
		// 称号附加属性
		MmochatChenHao equip = getCurChenHao();
		if (equip != null) {
			equipValue += equip
					.getEquipAttrValue(MmochatEquipAttributeType.法术暴击抵抗);
		}
		// 强化丹效果
		{
			equipValue += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.法术暴击抵抗);
		}
		return equipValue;
	}

	// 获取法术破防
	@Override
	public int getMagicDefendIgnore() {
		int equipValue = 0;
		for (MmochatEquipPlaceType place : MmochatEquipPlaceType.values()) {
			MmochatPackageGrid grid = myPackage.get(place.getValue());
			if (grid != null && grid.getObject() != null) {
				MmochatCommonObject equip = grid.getObject();
				if (equip != null) {
					equipValue += equip
							.getEquipAttrValue(MmochatEquipAttributeType.法术破防);
				}
			}
		}
		// 称号附加属性
		MmochatChenHao equip = getCurChenHao();
		if (equip != null) {
			equipValue += equip
					.getEquipAttrValue(MmochatEquipAttributeType.法术破防);
		}
		// 强化丹效果
		{
			equipValue += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.法术破防);
		}
		return equipValue;
	}

	// 获取法免
	@Override
	public int getMagicDefendPercent() {
		int equipValue = 0;
		for (MmochatEquipPlaceType place : MmochatEquipPlaceType.values()) {
			MmochatPackageGrid grid = myPackage.get(place.getValue());
			if (grid != null && grid.getObject() != null) {
				MmochatCommonObject equip = grid.getObject();
				if (equip != null) {
					equipValue += equip
							.getEquipAttrValue(MmochatEquipAttributeType.法术免疫);
					equipValue += equip
							.getEquipAttrValue(MmochatEquipAttributeType.免伤);
				}
			}
		}
		// 称号附加属性
		MmochatChenHao equip = getCurChenHao();
		if (equip != null) {
			equipValue += equip
					.getEquipAttrValue(MmochatEquipAttributeType.法术免疫);
			equipValue += equip.getEquipAttrValue(MmochatEquipAttributeType.免伤);
		}
		// 强化丹效果
		{
			equipValue += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.法术免疫);
			equipValue += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.免伤);
		}
		return equipValue;
	}

	// 获取法术致使一击(2倍伤害)
	@Override
	public int getMagicDoubleAttack() {
		int equipValue = 0;
		for (MmochatEquipPlaceType place : MmochatEquipPlaceType.values()) {
			MmochatPackageGrid grid = myPackage.get(place.getValue());
			if (grid != null && grid.getObject() != null) {
				MmochatCommonObject equip = grid.getObject();
				if (equip != null) {
					equipValue += equip
							.getEquipAttrValue(MmochatEquipAttributeType.法术致命一击);
				}
			}
		}
		// 称号附加属性
		MmochatChenHao equip = getCurChenHao();
		if (equip != null) {
			equipValue += equip
					.getEquipAttrValue(MmochatEquipAttributeType.法术致命一击);
		}
		// 强化丹效果
		{
			equipValue += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.法术致命一击);
		}
		return equipValue;
	}

	// 获取法术致使一击抵抗
	@Override
	public int getMagicDoubleAttackDefend() {
		int equipValue = 0;
		for (MmochatEquipPlaceType place : MmochatEquipPlaceType.values()) {
			MmochatPackageGrid grid = myPackage.get(place.getValue());
			if (grid != null && grid.getObject() != null) {
				MmochatCommonObject equip = grid.getObject();
				if (equip != null) {
					equipValue += equip
							.getEquipAttrValue(MmochatEquipAttributeType.法术致命抵抗);
				}
			}
		}
		// 称号附加属性
		MmochatChenHao equip = getCurChenHao();
		if (equip != null) {
			equipValue += equip
					.getEquipAttrValue(MmochatEquipAttributeType.法术致命抵抗);
		}
		// 强化丹效果
		{
			equipValue += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.法术致命抵抗);
		}
		return equipValue;
	}

	// 获取物理暴击(1.5倍伤害)
	@Override
	public int getPhysicalDeadlyAttack() {
		int equipValue = 0;
		for (MmochatEquipPlaceType place : MmochatEquipPlaceType.values()) {
			MmochatPackageGrid grid = myPackage.get(place.getValue());
			if (grid != null && grid.getObject() != null) {
				MmochatCommonObject equip = grid.getObject();
				if (equip != null) {
					equipValue += equip
							.getEquipAttrValue(MmochatEquipAttributeType.物理暴击);
				}
			}
		}
		// 称号附加属性
		MmochatChenHao equip = getCurChenHao();
		if (equip != null) {
			equipValue += equip
					.getEquipAttrValue(MmochatEquipAttributeType.物理暴击);
		}
		// 强化丹效果
		{
			equipValue += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.物理暴击);
		}
		return equipValue;
	}

	// 获取物理暴击抵抗
	@Override
	public int getPhysicalDeadlyAttackDefend() {
		int equipValue = 0;
		for (MmochatEquipPlaceType place : MmochatEquipPlaceType.values()) {
			MmochatPackageGrid grid = myPackage.get(place.getValue());
			if (grid != null && grid.getObject() != null) {
				MmochatCommonObject equip = grid.getObject();
				if (equip != null) {
					equipValue += equip
							.getEquipAttrValue(MmochatEquipAttributeType.物理暴击抵抗);
				}
			}
		}
		// 称号附加属性
		MmochatChenHao equip = getCurChenHao();
		if (equip != null) {
			equipValue += equip
					.getEquipAttrValue(MmochatEquipAttributeType.物理暴击抵抗);
		}
		// 强化丹效果
		{
			equipValue += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.物理暴击抵抗);
		}
		return equipValue;
	}

	// 获取物理破防
	@Override
	public int getPhysicalDefendIgnore() {
		int equipValue = 0;
		for (MmochatEquipPlaceType place : MmochatEquipPlaceType.values()) {
			MmochatPackageGrid grid = myPackage.get(place.getValue());
			if (grid != null && grid.getObject() != null) {
				MmochatCommonObject equip = grid.getObject();
				if (equip != null) {
					equipValue += equip
							.getEquipAttrValue(MmochatEquipAttributeType.物理破防);
				}
			}
		}
		// 称号附加属性
		MmochatChenHao equip = getCurChenHao();
		if (equip != null) {
			equipValue += equip
					.getEquipAttrValue(MmochatEquipAttributeType.物理破防);
		}
		// 强化丹效果
		{
			equipValue += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.物理破防);
		}
		return equipValue;
	}

	// 获取物免
	@Override
	public int getPhysicalDefendPercent() {
		int equipValue = 0;
		for (MmochatEquipPlaceType place : MmochatEquipPlaceType.values()) {
			MmochatPackageGrid grid = myPackage.get(place.getValue());
			if (grid != null && grid.getObject() != null) {
				MmochatCommonObject equip = grid.getObject();
				if (equip != null) {
					equipValue += equip
							.getEquipAttrValue(MmochatEquipAttributeType.物理免疫);
					equipValue += equip
							.getEquipAttrValue(MmochatEquipAttributeType.免伤);
				}
			}
		}
		// 称号附加属性
		MmochatChenHao equip = getCurChenHao();
		if (equip != null) {
			equipValue += equip
					.getEquipAttrValue(MmochatEquipAttributeType.物理免疫);
			equipValue += equip.getEquipAttrValue(MmochatEquipAttributeType.免伤);
		}
		// 强化丹效果
		{
			equipValue += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.物理免疫);
			equipValue += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.免伤);
		}
		return equipValue;
	}

	// 获取物理致命一击(2倍伤害)
	@Override
	public int getPhysicalDoubleAttack() {
		int equipValue = 0;
		for (MmochatEquipPlaceType place : MmochatEquipPlaceType.values()) {
			MmochatPackageGrid grid = myPackage.get(place.getValue());
			if (grid != null && grid.getObject() != null) {
				MmochatCommonObject equip = grid.getObject();
				if (equip != null) {
					equipValue += equip
							.getEquipAttrValue(MmochatEquipAttributeType.物理致命一击);
				}
			}
		}
		// 称号附加属性
		MmochatChenHao equip = getCurChenHao();
		if (equip != null) {
			equipValue += equip
					.getEquipAttrValue(MmochatEquipAttributeType.物理致命一击);
		}
		// 强化丹效果
		{
			equipValue += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.物理致命一击);
		}
		return equipValue;
	}

	// 获取物理致命一击抵抗
	@Override
	public int getPhysicalDoubleAttackDefend() {
		int equipValue = 0;
		for (MmochatEquipPlaceType place : MmochatEquipPlaceType.values()) {
			MmochatPackageGrid grid = myPackage.get(place.getValue());
			if (grid != null && grid.getObject() != null) {
				MmochatCommonObject equip = grid.getObject();
				if (equip != null) {
					equipValue += equip
							.getEquipAttrValue(MmochatEquipAttributeType.物理致命抵抗);
				}
			}
		}
		// 称号附加属性
		MmochatChenHao equip = getCurChenHao();
		if (equip != null) {
			equipValue += equip
					.getEquipAttrValue(MmochatEquipAttributeType.物理致命抵抗);
		}
		// 强化丹效果
		{
			equipValue += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.物理致命抵抗);
		}
		return equipValue;
	}

	// 获取强力混乱
	@Override
	public int getStrengthenConfuse() {
		int equipValue = 0;
		for (MmochatEquipPlaceType place : MmochatEquipPlaceType.values()) {
			MmochatPackageGrid grid = myPackage.get(place.getValue());
			if (grid != null && grid.getObject() != null) {
				MmochatCommonObject equip = grid.getObject();
				if (equip != null) {
					equipValue += equip
							.getEquipAttrValue(MmochatEquipAttributeType.强化混乱);
					equipValue += equip
							.getEquipAttrValue(MmochatEquipAttributeType.强化全异常);
				}
			}
		}
		// 称号附加属性
		MmochatChenHao equip = getCurChenHao();
		if (equip != null) {
			equipValue += equip
					.getEquipAttrValue(MmochatEquipAttributeType.强化混乱);
			equipValue += equip
					.getEquipAttrValue(MmochatEquipAttributeType.强化全异常);
		}
		// 强化丹效果
		{
			equipValue += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.强化混乱);
			equipValue += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.强化全异常);
		}
		return equipValue;
	}

	// 获取强力冰冻
	@Override
	public int getStrengthenFreeze() {
		int equipValue = 0;
		for (MmochatEquipPlaceType place : MmochatEquipPlaceType.values()) {
			MmochatPackageGrid grid = myPackage.get(place.getValue());
			if (grid != null && grid.getObject() != null) {
				MmochatCommonObject equip = grid.getObject();
				if (equip != null) {
					equipValue += equip
							.getEquipAttrValue(MmochatEquipAttributeType.强化冰冻);
					equipValue += equip
							.getEquipAttrValue(MmochatEquipAttributeType.强化全异常);
				}
			}
		}
		// 称号附加属性
		MmochatChenHao equip = getCurChenHao();
		if (equip != null) {
			equipValue += equip
					.getEquipAttrValue(MmochatEquipAttributeType.强化冰冻);
			equipValue += equip
					.getEquipAttrValue(MmochatEquipAttributeType.强化全异常);
		}
		// 强化丹效果
		{
			equipValue += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.强化冰冻);
			equipValue += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.强化全异常);
		}
		return equipValue;
	}

	// 获取强力封印
	@Override
	public int getStrengthenSeal() {
		int equipValue = 0;
		for (MmochatEquipPlaceType place : MmochatEquipPlaceType.values()) {
			MmochatPackageGrid grid = myPackage.get(place.getValue());
			if (grid != null && grid.getObject() != null) {
				MmochatCommonObject equip = grid.getObject();
				if (equip != null) {
					equipValue += equip
							.getEquipAttrValue(MmochatEquipAttributeType.强化封印);
					equipValue += equip
							.getEquipAttrValue(MmochatEquipAttributeType.强化全异常);
				}
			}
		}
		// 称号附加属性
		MmochatChenHao equip = getCurChenHao();
		if (equip != null) {
			equipValue += equip
					.getEquipAttrValue(MmochatEquipAttributeType.强化封印);
			equipValue += equip
					.getEquipAttrValue(MmochatEquipAttributeType.强化全异常);
		}
		// 强化丹效果
		{
			equipValue += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.强化封印);
			equipValue += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.强化全异常);
		}
		return equipValue;
	}

	// 获取抗雷
	public int getAntiGodSkill() {
		int equipValue = 0;
		for (MmochatEquipPlaceType place : MmochatEquipPlaceType.values()) {
			MmochatPackageGrid grid = myPackage.get(place.getValue());
			if (grid != null && grid.getObject() != null) {
				MmochatCommonObject equip = grid.getObject();
				if (equip != null) {
					equipValue += equip
							.getEquipAttrValue(MmochatEquipAttributeType.抗雷);
				}
			}
		}
		// 称号附加属性
		MmochatChenHao equip = getCurChenHao();
		if (equip != null) {
			equipValue += equip.getEquipAttrValue(MmochatEquipAttributeType.抗雷);
		}
		// 强化丹效果
		{
			equipValue += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.抗雷);
		}
		return equipValue;
	}

	// 获取抗水
	public int getAntiHumanSkill() {
		int equipValue = 0;
		for (MmochatEquipPlaceType place : MmochatEquipPlaceType.values()) {
			MmochatPackageGrid grid = myPackage.get(place.getValue());
			if (grid != null && grid.getObject() != null) {
				MmochatCommonObject equip = grid.getObject();
				if (equip != null) {
					equipValue += equip
							.getEquipAttrValue(MmochatEquipAttributeType.抗水);
				}
			}
		}
		// 称号附加属性
		MmochatChenHao equip = getCurChenHao();
		if (equip != null) {
			equipValue += equip.getEquipAttrValue(MmochatEquipAttributeType.抗水);
		}
		// 强化丹效果
		{
			equipValue += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.抗水);
		}
		return equipValue;
	}

	// 获取抗毒
	public int getAntiDevilSkill() {
		int equipValue = 0;
		for (MmochatEquipPlaceType place : MmochatEquipPlaceType.values()) {
			MmochatPackageGrid grid = myPackage.get(place.getValue());
			if (grid != null && grid.getObject() != null) {
				MmochatCommonObject equip = grid.getObject();
				if (equip != null) {
					equipValue += equip
							.getEquipAttrValue(MmochatEquipAttributeType.抗毒);
				}
			}
		}
		// 称号附加属性
		MmochatChenHao equip = getCurChenHao();
		if (equip != null) {
			equipValue += equip.getEquipAttrValue(MmochatEquipAttributeType.抗毒);
		}
		// 强化丹效果
		{
			equipValue += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.抗毒);
		}
		return equipValue;
	}

	// 忽视抗雷
	public int getIgnoreAntiGodSkill() {
		int equipValue = 0;
		for (MmochatEquipPlaceType place : MmochatEquipPlaceType.values()) {
			MmochatPackageGrid grid = myPackage.get(place.getValue());
			if (grid != null && grid.getObject() != null) {
				MmochatCommonObject equip = grid.getObject();
				if (equip != null) {
					equipValue += equip
							.getEquipAttrValue(MmochatEquipAttributeType.忽视抗雷);
				}
			}
		}
		// 称号附加属性
		MmochatChenHao equip = getCurChenHao();
		if (equip != null) {
			equipValue += equip
					.getEquipAttrValue(MmochatEquipAttributeType.忽视抗雷);
		}
		// 强化丹效果
		{
			equipValue += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.忽视抗雷);
		}
		return equipValue;
	}

	// 忽视抗水
	public int getIgnoreAntiHumanSkill() {
		int equipValue = 0;
		for (MmochatEquipPlaceType place : MmochatEquipPlaceType.values()) {
			MmochatPackageGrid grid = myPackage.get(place.getValue());
			if (grid != null && grid.getObject() != null) {
				MmochatCommonObject equip = grid.getObject();
				if (equip != null) {
					equipValue += equip
							.getEquipAttrValue(MmochatEquipAttributeType.忽视抗水);
				}
			}
		}
		// 称号附加属性
		MmochatChenHao equip = getCurChenHao();
		if (equip != null) {
			equipValue += equip
					.getEquipAttrValue(MmochatEquipAttributeType.忽视抗水);
		}
		// 强化丹效果
		{
			equipValue += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.忽视抗水);
		}
		return equipValue;
	}

	// 忽视抗毒
	public int getIgnoreAntiDevilSkill() {
		int equipValue = 0;
		for (MmochatEquipPlaceType place : MmochatEquipPlaceType.values()) {
			MmochatPackageGrid grid = myPackage.get(place.getValue());
			if (grid != null && grid.getObject() != null) {
				MmochatCommonObject equip = grid.getObject();
				if (equip != null) {
					equipValue += equip
							.getEquipAttrValue(MmochatEquipAttributeType.忽视抗毒);
				}
			}
		}
		// 称号附加属性
		MmochatChenHao equip = getCurChenHao();
		if (equip != null) {
			equipValue += equip
					.getEquipAttrValue(MmochatEquipAttributeType.忽视抗毒);
		}
		// 强化丹效果
		{
			equipValue += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.忽视抗毒);
		}
		return equipValue;
	}

	// 获取神圣物理伤害(物理攻击对方时，对方实际掉血量=MAX(神圣物理伤害,普通物伤造成的掉血量))
	@Override
	public int getSuperPhysicalAttack() {
		int equipValue = 0;
		for (MmochatEquipPlaceType place : MmochatEquipPlaceType.values()) {
			MmochatPackageGrid grid = myPackage.get(place.getValue());
			if (grid != null && grid.getObject() != null) {
				MmochatCommonObject equip = grid.getObject();
				if (equip != null) {
					equipValue += equip
							.getEquipAttrValue(MmochatEquipAttributeType.神圣物理伤害);
				}
			}
		}
		// 称号附加属性
		MmochatChenHao equip = getCurChenHao();
		if (equip != null) {
			equipValue += equip
					.getEquipAttrValue(MmochatEquipAttributeType.神圣物理伤害);
		}
		// 强化丹效果
		{
			equipValue += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.神圣物理伤害);
		}
		return equipValue;
	}

	// 获取神圣法术伤害(法术攻击对方时，对方实际掉血量=MAX(神圣法术伤害,普通法伤造成的掉血量))
	@Override
	public int getSuperSpritAttack() {
		int equipValue = 0;
		for (MmochatEquipPlaceType place : MmochatEquipPlaceType.values()) {
			MmochatPackageGrid grid = myPackage.get(place.getValue());
			if (grid != null && grid.getObject() != null) {
				MmochatCommonObject equip = grid.getObject();
				if (equip != null) {
					equipValue += equip
							.getEquipAttrValue(MmochatEquipAttributeType.神圣法术伤害);
				}
			}
		}
		// 称号附加属性
		MmochatChenHao equip = getCurChenHao();
		if (equip != null) {
			equipValue += equip
					.getEquipAttrValue(MmochatEquipAttributeType.神圣法术伤害);
		}
		// 强化丹效果
		{
			equipValue += MmochatStrengthDrug.getEquipAttrValue(this,
					MmochatEquipAttributeType.神圣法术伤害);
		}
		return equipValue;
	}

	// 获取特定类型属性数值:此属性类型要求是独立类型，其它类型不能与之有交集。
	// 如野蛮--全天赋，就有交集，不能使用此方法
	public int getCommonEquipAttributeValue(MmochatEquipAttributeType type) {
		int equipValue = 0;
		for (MmochatEquipPlaceType place : MmochatEquipPlaceType.values()) {
			MmochatPackageGrid grid = myPackage.get(place.getValue());
			if (grid != null && grid.getObject() != null) {
				MmochatCommonObject equip = grid.getObject();
				if (equip != null) {
					equipValue += equip.getEquipAttrValue(type);
				}
			}
		}
		// 称号附加属性
		MmochatChenHao equip = getCurChenHao();
		if (equip != null) {
			equipValue += equip.getEquipAttrValue(type);
		}
		// 强化丹效果
		{
			equipValue += MmochatStrengthDrug.getEquipAttrValue(this, type);
		}
		return equipValue;

	}

	public Map<MmochatSmeType, MmochatSme> getSme() {
		return sme;
	}

	public void setSme(Map<MmochatSmeType, MmochatSme> sme) {
		this.sme = new ConcurrentHashMap<MmochatSmeType, MmochatSme>(sme);
	}

	public long getSmeValue() {
		long value = 0;
		for (MmochatSmeType type : sme.keySet()) {
			value += type.getValue();
		}
		return value;
	}

	public void addSme(MmochatSme newSme) {
		if (newSme != null && newSme.getKeepRound() > 0) {
			sme.put(newSme.getType(), newSme);
		}
	}

	// 每回合过后障碍效果保持回合数减1
	public MmochatSmeResult decreaseSme() {
		boolean hasReset = false;
		boolean hasChange = false;
		for (MmochatSme s : sme.values()) {
			s.decreaseKeepRound();
			if (s.getKeepRound() <= 0) {
				sme.remove(s.getType());
				switch (s.getType()) {
				case 三魂丹:
				case 七魄丹: {
					hasReset = true;
					break;
				}
				default:
					hasChange = true;
					break;
				}
			}
		}
		if (hasReset && hasChange) {
			return MmochatSmeResult.重设角色及变更状态;
		}
		if (hasReset) {
			return MmochatSmeResult.重设角色;
		}
		if (hasChange) {
			return MmochatSmeResult.变更状态;
		}
		return MmochatSmeResult.无变更;
	}

	public void delSme(MmochatSmeType type) {
		sme.remove(type);
	}

	public int getBlood_point() {
		return blood_point;
	}

	public void setBlood_point(int bloodPoint) {
		blood_point = bloodPoint;
	}

	public int getAttack_point() {
		return attack_point;
	}

	public void setAttack_point(int attackPoint) {
		attack_point = attackPoint;
	}

	public int getSprit_point() {
		return sprit_point;
	}

	public void setSprit_point(int spritPoint) {
		sprit_point = spritPoint;
	}

	public int getSpeed_point() {
		return speed_point;
	}

	public void setSpeed_point(int speedPoint) {
		speed_point = speedPoint;
	}

	public void delBlood_point(int del) {
		blood_point -= del;
	}

	public void delAttack_point(int del) {
		attack_point -= del;
	}

	public void delSprit_point(int del) {
		sprit_point -= del;
	}

	public void delSpeed_point(int del) {
		speed_point -= del;
	}

	public void addSpace_point(int add) {
		space_point += add;
	}

	public void delCurPkBlood(int delBlood) {
		curPkBlood -= delBlood;
		curPkBlood = Math.max(0, curPkBlood);
		curPkBlood = Math.min(getTotalBlood(), curPkBlood);
	}

	public void delCurPkSprit(int delSprit) {
		curPkSprit -= delSprit;
		curPkSprit = Math.max(0, curPkSprit);
		curPkSprit = Math.min(getTotalSprit(), curPkSprit);
	}

	public Map<Integer, Integer> getTmpNpcs() {
		return tmpNpcs;
	}

	public void setTmpNpcs(Map<Integer, Integer> tmpNpcs) {
		this.tmpNpcs = new ConcurrentHashMap<Integer, Integer>(tmpNpcs);
	}

	public void addTmpNpc(int npcId) {
		tmpNpcs.put(npcId, npcId);
	}

	public void delTmpNpc(int npcId) {
		if (tmpNpcs.containsKey(npcId)) {
			tmpNpcs.remove(npcId);
		}
	}

	public MmochatTask getTaskById(int taskId) {
		MmochatTask t = tasks.get(taskId);
		return t;
	}

	public Map<Integer, MmochatTask> getTasks() {
		return tasks;
	}

	public void setTasks(Map<Integer, MmochatTask> tasks) {
		this.tasks = new ConcurrentHashMap<Integer, MmochatTask>(tasks);
	}

	public void addTask(MmochatTask task) {
		tasks.put(task.getTaskId(), task);
	}

	public MmochatTask getTaskByType(MmochatTaskType type) {
		for (MmochatTask t : tasks.values()) {
			if (t.getTaskType() == type) {
				return t;
			}
		}
		return null;
	}

	public MmochatTask getUnFinishedTaskByType(MmochatTaskType type) {
		for (MmochatTask t : tasks.values()) {
			if (t.getTaskType() == type
					&& t.getTaskState() != MmochatTaskStateType.已完成) {
				return t;
			}
		}
		return null;
	}

	public boolean hasFinished(int taskId) {
		MmochatTask task = getTaskById(taskId);
		if (task == null) {
			return false;
		}
		if (task.getTaskState() == MmochatTaskStateType.已完成) {
			return true;
		}
		return false;
	}

	public List<MmochatTask> getUnfinishedTasks() {
		List<MmochatTask> task = new ArrayList<MmochatTask>();
		for (MmochatTask t : tasks.values()) {
			if (t.getTaskState() == MmochatTaskStateType.已接) {
				task.add(t);
			}
		}
		return task;
	}

	// 是否可以接此任务(临时任务不用此作检测)
	@SuppressWarnings("deprecation")
	public boolean canAcceptTask(int taskId) {
		boolean continueCheck = false;
		MmochatTask task = getTaskById(taskId);
		// 新任务
		if (task == null) {
			task = MmochatTaskService.getTaskById(taskId);
			continueCheck = true;
		} else if (task.getTaskState() == MmochatTaskStateType.未接) {
			continueCheck = true;
		}

		// 过度任务
		else if (task.getTaskType() == MmochatTaskType.过渡任务) {
			task = MmochatTaskService.getTaskById(taskId);
			continueCheck = true;
		}

		// 每日任务
		/*
		 * A->B->C
		 * 
		 * A设置为每日任务，BC设置为普通任务,
		 * A设置<taskContinue>true</taskContinue>,表示完成A后，设置A为待完成
		 * C设置<finishAnotherTask>A任务的taskId</finishAnotherTask>
		 * 
		 * A：已接-->待完成-->完成(C完成后设置A为完成)
		 */
		else if ((task.getTaskState() == MmochatTaskStateType.已完成)
				&& (task.getTaskType() == MmochatTaskType.每日大众任务 || task
						.getTaskType() == MmochatTaskType.每日等级任务)) {
			long time = task.getFinish_time();
			Date finishTime = new Date(time);
			Date now = new Date();
			if (finishTime.getYear() == now.getYear()
					&& finishTime.getMonth() == now.getMonth()
					&& finishTime.getDate() == now.getDate()) {
				return false;
			}
			continueCheck = true;
		}

		if (continueCheck && task != null) {
			if (task.canAccept(this)) {
				return true;
			}
		}
		return false;
	}

	// 是否可以完成此任务
	public boolean canFinishTask(int taskId) {
		MmochatTask task = getTaskById(taskId);
		if (task != null && task.getTaskState() == MmochatTaskStateType.已接
				&& task.getTaskType() != MmochatTaskType.过渡任务) {
			if (task.canFinish(this)) {
				return true;
			}
		}
		return false;
	}

	// 是否是未完成任务
	public boolean isNotFinishTask(int taskId) {
		MmochatTask task = getTaskById(taskId);
		if (task != null && task.getTaskState() == MmochatTaskStateType.已接
				&& task.getTaskType() != MmochatTaskType.过渡任务) {
			if (!task.canFinish(this)) {
				return true;
			}
		}
		return false;
	}

	// 已接任务数是否已满
	public boolean isTaskFull() {
		List<MmochatTask> task = new ArrayList<MmochatTask>();
		for (MmochatTask t : tasks.values()) {
			if (t.getTaskState() == MmochatTaskStateType.已接
					&& t.getTaskType() != MmochatTaskType.过渡任务
					&& t.getTaskType() != MmochatTaskType.寻宝任务) {
				task.add(t);
			}
		}
		return task.size() >= MmochatConstant.maxUnfinishedTaskNum;
	}

	// 是否在同一屏幕(同地图,同线,距离相近)
	public boolean isInSameScreen(MmochatPlayer role) {
		if (role == null) {
			return false;
		}
		if (role.getMapId() != mapId) {
			return false;
		}
		if (role.getLine() != line) {
			return false;
		}
		if (Math.abs(role.getX() - x) < MmochatConstant.screenWidth
				&& Math.abs(role.getY() - y) < MmochatConstant.screenHeight) {
			return true;
		}
		return false;
	}

	// 是否在同一地图同一线
	public boolean isInSameMapLine(MmochatPlayer role) {
		if (role == null) {
			return false;
		}
		if (role.getMapId() != mapId) {
			return false;
		}
		if (role.getLine() != line) {
			return false;
		}
		return true;
	}

	public long getSmall_money() {
		return small_money;
	}

	public void setSmall_money(int smallMoney) {
		small_money = smallMoney;
	}

	public synchronized void addSmall_money(long addMoney) {
		small_money += (long) addMoney;
		small_money = Math.max(0, small_money);
		small_money = Math.min(small_money, (long) Integer.MAX_VALUE);
	}

	public synchronized void addSmall_money(int addMoney) {
		small_money += (long) addMoney;
		small_money = Math.max(0, small_money);
		small_money = Math.min(small_money, (long) Integer.MAX_VALUE);
	}

	public void addAndUpdateSmall_money(long addMoney) {
		synchronized (this) {
			small_money += (long) addMoney;
			small_money = Math.max(0, small_money);
			small_money = Math.min(small_money, (long) Integer.MAX_VALUE);
		}
		// 更新包裹金钱
		Mmochat_5_31S pack = new Mmochat_5_31S();
		pack.setSmallMoney((int) small_money);
		MmochatUtil.sendCommonPack(this, pack);
	}

	public void addAndUpdateSmall_money(int addMoney) {
		synchronized (this) {
			small_money += (long) addMoney;
			small_money = Math.max(0, small_money);
			small_money = Math.min(small_money, (long) Integer.MAX_VALUE);
		}
		// 更新包裹金钱
		Mmochat_5_31S pack = new Mmochat_5_31S();
		pack.setSmallMoney((int) small_money);
		MmochatUtil.sendCommonPack(this, pack);
	}

	public long getBig_money() {
		return big_money;
	}

	public void setBig_money(int bigMoney) {
		big_money = bigMoney;
	}

	public synchronized void addBig_money(int addMoney) {
		big_money += (long) addMoney;
		big_money = Math.max(0, big_money);
		big_money = Math.min(big_money, (long) Integer.MAX_VALUE);
	}

	// 是否可以进行交易
	public boolean canDeal() {
		// TODO:如设置了拒绝交易
		if (isInDeal()) {
			return false;
		}
		if (isInBattle()) {
			return false;
		}
		return true;
	}

	// 请求交易
	public void requestDeal(MmochatPlayer p) {
		if (p == null) {
			return;
		}
		MmochatDealService.startDeal(this, p);
	}

	public int getDealId() {
		return dealId;
	}

	public void setDealId(int dealId) {
		this.dealId = dealId;
	}

	public void stopDeal() {
		if (isInDeal()) {
			MmochatDeal deal = MmochatDealService.deals.get(dealId);
			if (deal != null) {
				deal.stopDeal(roleId);
			}
		}
		dealId = 0;
	}

	public boolean isInDeal() {
		return dealId > 0;
	}

	public boolean isAlive() {
		return System.currentTimeMillis() - latestActiveTime < MmochatConstant
				.getRoleTimeOutTime();
	}

	public boolean isLeaveGame() {
		return System.currentTimeMillis() - latestActiveTime > MmochatConstant.roleLeaveGameTime;
	}

	// 去除包裹和仓库中过期的道具
	public boolean checkTimedProp() {
		boolean updatePackage = false;
		List<MmochatPackageGrid> gridNeedUpdate = new ArrayList<MmochatPackageGrid>();
		for (MmochatPackageGrid grid : myPackage.values()) {
			if (grid != null && grid.getObject() != null) {
				MmochatCommonObject gridObj = grid.getObject();
				if (gridObj.getPropType() != null) {
					MmochatPropType propType = gridObj.getPropType();
					if (propType.getEffectType() == MmochatPropEffectType.限时不限量
							|| propType.getEffectType() == MmochatPropEffectType.限时) {
						if (gridObj.getStartTick() != null) {
							long costTime = System.currentTimeMillis()
									- gridObj.getStartTick();
							if (costTime >= propType.getEffectAmount()) {
								// 过期
								grid.setObject(null);
								gridNeedUpdate.add(grid);
								updatePackage = true;
							}
						}
					}
				}
			}
		}
		if (gridNeedUpdate.size() > 0) {
			Mmochat_5_1S pack = new Mmochat_5_1S();
			pack.setGrids(gridNeedUpdate);
			MmochatUtil.sendCommonPack(this, pack);
		}
		boolean updateStore = false;
		for (MmochatPackageGrid grid : myStorage.values()) {
			if (grid != null && grid.getObject() != null) {
				MmochatCommonObject gridObj = grid.getObject();
				if (gridObj.getPropType() != null) {
					MmochatPropType propType = gridObj.getPropType();
					if (propType.getEffectType() == MmochatPropEffectType.限时不限量
							|| propType.getEffectType() == MmochatPropEffectType.限时) {
						if (gridObj.getStartTick() != null) {
							long costTime = System.currentTimeMillis()
									- gridObj.getStartTick();
							if (costTime >= propType.getEffectAmount()) {
								// 过期
								grid.setObject(null);
								updateStore = true;
							}
						}
					}
				}
			}
		}
		if (updatePackage && updateStore) {
			try {
				MmochatDao.updateMyPackageAndStorage(this);
			} catch (Exception e) {
				e.printStackTrace();
			}
			return true;
		} else if (updatePackage) {
			try {
				MmochatDao.updateMyPackage(this);
			} catch (Exception e) {
				e.printStackTrace();
			}
			return true;
		} else if (updateStore) {
			try {
				MmochatDao.updateMyStorage(this);
			} catch (Exception e) {
				e.printStackTrace();
			}
			return true;
		}
		return false;
	}

	public List<MmochatCommonObject> getFirstPageDrugs() {
		List<MmochatCommonObject> drugList = new ArrayList<MmochatCommonObject>();

		for (int i = MmochatConstant.packageGridIndexHead; i <= MmochatConstant.packageGridIndexHead + 19; i++) {
			MmochatPackageGrid grid = myPackage.get(i);
			if (grid != null && grid.isCanUse() && grid.getObject() != null) {
				MmochatCommonObject gridObj = grid.getObject();
				if (gridObj.getObjectType() == MmochatObjectType.药品) {
					drugList.add(gridObj);
				}
			}
		}
		return drugList;
	}

	public boolean addDrug(MmochatDrugType type, int num) {
		if (num < 0) {
			throw new RuntimeException("addDrug num是负数");
		}
		if (type == null || num == 0) {
			return true;
		}
		MmochatCommonObject obj = new MmochatCommonObject();
		obj.setObjectType(MmochatObjectType.药品);
		obj.setCanOverlap(true);
		obj.setOverlapNum(num);
		obj.setCanDeal(true);
		obj.setDrugType(type);
		return addObjectToPackage(obj);
	}

	public boolean addDrugNoDeal(MmochatDrugType type, int num) {
		if (num < 0) {
			throw new RuntimeException("addDrug num是负数");
		}
		if (type == null || num == 0) {
			return true;
		}
		MmochatCommonObject obj = new MmochatCommonObject();
		obj.setObjectType(MmochatObjectType.药品);
		obj.setCanOverlap(true);
		obj.setOverlapNum(num);
		obj.setCanDeal(false);
		obj.setDrugType(type);
		return addObjectToPackage(obj);
	}

	public boolean addMaterial(MmochatMaterialType type, int num) {
		if (type == null || num == 0) {
			return true;
		}
		MmochatCommonObject obj = new MmochatCommonObject();
		obj.setObjectType(MmochatObjectType.材料);
		obj.setCanOverlap(true);
		obj.setOverlapNum(num);
		obj.setCanDeal(true);
		obj.setMaterialType(type);
		return addObjectToPackage(obj);
	}

	public void addMaterial(List<MmochatMaterial> materialList) {
		if (materialList == null) {
			return;
		}
		for (MmochatMaterial m : materialList) {
			addMaterial(m.getType(), 1);
		}
	}

	public MmochatFamilyType getFamily() {
		return family;
	}

	public void setFamily(MmochatFamilyType family) {
		this.family = family;
	}

	public Map<MmochatSkillType, MmochatSkill> getSkills() {
		return skills;
	}

	public void setSkills(Map<MmochatSkillType, MmochatSkill> skills) {
		this.skills = new ConcurrentHashMap<MmochatSkillType, MmochatSkill>(
				skills);
	}

	public void addNewSkill(MmochatSkill skill) {
		skills.put(skill.getType(), skill);
	}

	public MmochatSkill getSkill(MmochatSkillType type) {
		return skills.get(type);
	}

	public int getSkillLevel(MmochatSkillType type) {
		int level = 0;
		MmochatSkill skill = skills.get(type);
		if (skill != null) {
			level = skill.getLevel();
		}
		return level;
	}

	public boolean isDeadConnection() {
		return deadConnection;
	}

	public void setDeadConnection(boolean deadConnection) {
		this.deadConnection = deadConnection;
	}

	public MmochatRoleBmpType getBmpType() {
		if (roleType.equals(MmochatRoleType.阐教男)) {
			return MmochatRoleBmpType.阐教男图;
		} else if (roleType.equals(MmochatRoleType.阐教女)) {
			return MmochatRoleBmpType.阐教女图;
		} else if (roleType.equals(MmochatRoleType.人教男)) {
			return MmochatRoleBmpType.人教男图;
		} else if (roleType.equals(MmochatRoleType.人教女)) {
			return MmochatRoleBmpType.人教女图;
		} else if (roleType.equals(MmochatRoleType.截教男)) {
			return MmochatRoleBmpType.截教男图;
		} else if (roleType.equals(MmochatRoleType.截教女)) {
			return MmochatRoleBmpType.截教女图;
		} else {
			// 怪形象
			MmochatMonster monster = MmochatPetService.monsterBaseAttrData
					.get(roleType);
			if (monster != null) {
				return monster.getBmpType();
			}
		}
		return null;
	}

	public Map<Integer, MmochatPet> getPets() {
		return pets;
	}

	public MmochatPet getPetAlongById(int id) {
		return pets.get(id);
	}

	public void setPets(Map<Integer, MmochatPet> newPets) {
		// 由于petId会临时生成，故map的key需要重新生成
		pets.clear();
		for (MmochatPet pet : newPets.values()) {
			pets.put(pet.getId(), pet);
		}
	}

	public MmochatPet getPkPet() {
		for (MmochatPet pet : pets.values()) {
			if (pet.getState().equals(MmochatPetStateType.参战)) {
				return pet;
			}
		}
		return null;
	}

	public MmochatPet getPetInBattle() {
		for (MmochatPet pet : pets.values()) {
			if (pet.isInPk()) {
				return pet;
			}
		}
		return null;
	}

	// 当前替补宠物
	public MmochatPet getBakPkPet() {
		for (MmochatPet pet : pets.values()) {
			if (pet.getState().equals(MmochatPetStateType.替补)) {
				return pet;
			}
		}
		return null;
	}

	public boolean isPetFull() {
		return pets.size() >= MmochatConstant.maxPetNumPerPackage;
	}

	public boolean addPet(MmochatPet pet) {
		if (pet == null) {
			return true;
		}
		if (isPetFull()) {
			return false;
		}
		pets.put(pet.getPetId(), pet);
		return true;
	}

	public MmochatPet delPet(int id) {
		return pets.remove(id);
	}

	public int getTeamId() {
		return teamId;
	}

	public void setTeamId(int teamId) {
		this.teamId = teamId;
	}

	public boolean isInTeam() {
		return teamId > 0;
	}

	public void leaveTeam() {
		teamId = 0;
	}

	public int getSpace_point() {
		return space_point;
	}

	public void setSpace_point(int spacePoint) {
		space_point = spacePoint;
	}

	public int getDao() {
		return dao;
	}

	public void setDao(int dao) {
		this.dao = dao;
	}

	public void addDao(int add) {
		long ret = (long) dao + add;
		dao = (int) Math.min(ret, Integer.MAX_VALUE);
		if (dao < 0) {
			dao = 0;
		}
	}

	public int getZhanji() {
		return zhanji;
	}

	public void setZhanji(int zhanji) {
		this.zhanji = zhanji;
	}

	public void addZhanji(int add) {
		this.zhanji += add;
		zhanji = Math.max(0, zhanji);
		zhanji = Math.min(MmochatConstant.zhanJiLimit, zhanji);
	}

	// 野外打怪增加战绩
	public boolean addNormalBattleZhanji(int addValue) {
		boolean add = false;
		if (zhanji < MmochatConstant.zhanJiLimitOfKillMonster) {
			zhanji += Math.min(addValue,
					MmochatConstant.zhanJiLimitOfKillMonster - zhanji);
			add = true;
		}
		return add;
	}

	public MmochatCommonObject getPackageObjById(int id) {
		for (MmochatPackageGrid grid : myPackage.values()) {
			MmochatCommonObject obj = grid.getObject();
			if (obj != null && obj.getId() == id) {
				return obj;
			}
		}
		return null;
	}

	public boolean hasSme(MmochatSmeType type) {
		if (sme == null || sme.size() == 0) {
			return false;
		}
		MmochatSme s = sme.get(type);
		if (s != null && s.getKeepRound() > 0) {
			return true;
		}
		return false;
	}

	public void setASpacePointToBlood(int num) {
		int trueNum = Math.min(num, space_point);
		if (trueNum > 0) {
			space_point -= trueNum;
			blood_point += trueNum;
		}
	}

	public void setASpacePointToAttack(int num) {
		int trueNum = Math.min(num, space_point);
		if (trueNum > 0) {
			space_point -= trueNum;
			attack_point += trueNum;
		}
	}

	public void setASpacePointToSprit(int num) {
		int trueNum = Math.min(num, space_point);
		if (trueNum > 0) {
			space_point -= trueNum;
			sprit_point += trueNum;
		}
	}

	public void setASpacePointToSpeed(int num) {
		int trueNum = Math.min(num, space_point);
		if (trueNum > 0) {
			space_point -= trueNum;
			speed_point += trueNum;
		}
	}

	public boolean setASpacePointToAttackGift(int num) {
		if (attack_gift_point >= MmochatConstant.getMaxNumPerGift(life_turn)) {
			return false;
		}
		int trueNum = Math.min(num, space_gift_point);
		trueNum = Math.min(trueNum, MmochatConstant.getMaxNumPerGift(life_turn)
				- attack_gift_point);
		if (trueNum > 0) {
			space_gift_point -= trueNum;
			attack_gift_point += trueNum;
		}
		return true;
	}

	public boolean setASpacePointToSpritGift(int num) {
		if (sprit_gift_point >= MmochatConstant.getMaxNumPerGift(life_turn)) {
			return false;
		}
		int trueNum = Math.min(num, space_gift_point);
		trueNum = Math.min(trueNum, MmochatConstant.getMaxNumPerGift(life_turn)
				- sprit_gift_point);
		if (trueNum > 0) {
			space_gift_point -= trueNum;
			sprit_gift_point += trueNum;
		}
		return true;
	}

	public boolean setASpacePointToBloodGift(int num) {
		if (blood_gift_point >= MmochatConstant.getMaxNumPerGift(life_turn)) {
			return false;
		}
		int trueNum = Math.min(num, space_gift_point);
		trueNum = Math.min(trueNum, MmochatConstant.getMaxNumPerGift(life_turn)
				- blood_gift_point);
		if (trueNum > 0) {
			space_gift_point -= trueNum;
			blood_gift_point += trueNum;
		}
		return true;
	}

	public boolean setASpacePointToDefendGift(int num) {
		if (defend_gift_point >= MmochatConstant.getMaxNumPerGift(life_turn)) {
			return false;
		}
		int trueNum = Math.min(num, space_gift_point);
		trueNum = Math.min(trueNum, MmochatConstant.getMaxNumPerGift(life_turn)
				- defend_gift_point);
		if (trueNum > 0) {
			space_gift_point -= trueNum;
			defend_gift_point += trueNum;
		}
		return true;
	}

	public boolean setASpacePointToSpeedGift(int num) {
		if (speed_gift_point >= MmochatConstant.getMaxNumPerGift(life_turn)) {
			return false;
		}
		int trueNum = Math.min(num, space_gift_point);
		trueNum = Math.min(trueNum, MmochatConstant.getMaxNumPerGift(life_turn)
				- speed_gift_point);
		if (trueNum > 0) {
			space_gift_point -= trueNum;
			speed_gift_point += trueNum;
		}
		return true;
	}

	public boolean isCanRescure() {
		return true;
	}

	public Map<Integer, MmochatFriend> getMyDearFriends() {
		return myDearFriends;
	}

	public void setMyDearFriends(Map<Integer, MmochatFriend> myDearFriends) {
		this.myDearFriends = new ConcurrentHashMap<Integer, MmochatFriend>(
				myDearFriends);
	}

	public Map<Integer, MmochatFriend> getMyEnermys() {
		return myEnermys;
	}

	public boolean isMyFriendsFull() {
		return myDearFriends.size() >= MmochatConstant.maxFriendNum;
	}

	public MmochatFriend addMyDearFriend(MmochatPlayer friend) {
		if (friend == null) {
			return null;
		}
		if (isMyFriendsFull()) {
			return null;
		}
		if (myDearFriends.containsKey(friend.getRoleId())) {
			return null;
		}
		MmochatFriend newFriend = new MmochatFriend();
		newFriend.setFriendValue(0);
		newFriend.setFriendListPrority(0);
		newFriend.setName(friend.getName());
		newFriend.setRoleId(friend.getRoleId());
		newFriend.setBmpId(friend.getBmpId());
		newFriend.setMoodInfo(friend.getMoodInfo());
		myDearFriends.put(friend.getRoleId(), newFriend);
		return newFriend;
	}

	public void setMyEnermys(Map<Integer, MmochatFriend> myEnermys) {
		this.myEnermys = new ConcurrentHashMap<Integer, MmochatFriend>(
				myEnermys);
	}

	public boolean isEnermyFull() {
		return myEnermys.size() >= MmochatConstant.maxEnermyNum;
	}

	public boolean addEnermy(MmochatFriend p) {
		if (p == null) {
			return false;
		}
		if (isEnermyFull()) {
			return false;
		}
		if (myEnermys.containsKey(p.getRoleId())) {
			return false;
		}
		myEnermys.put(p.getRoleId(), p);
		return true;
	}

	public ArrayBlockingQueue<MmochatFriend> getMyTempFriends() {
		return myTempFriends;
	}

	public void setMyTempFriends(ArrayBlockingQueue<MmochatFriend> myTempFriends) {
		this.myTempFriends = myTempFriends;
		for (MmochatFriend friend : myTempFriends) {
			myTempFriendsMap.put(friend.getRoleId(), friend);
		}
	}

	public MmochatFriend[] getMyTempFriendsArray() {
		if (myTempFriends == null || myTempFriends.size() == 0) {
			return null;
		}
		MmochatFriend[] tmpFriends = new MmochatFriend[myTempFriends.size()];
		tmpFriends = myTempFriends.toArray(tmpFriends);
		return tmpFriends;
	}

	public MmochatFriend getFriendFromTemp(int roleId) {
		for (MmochatFriend oldFriend : myTempFriends) {
			if (oldFriend.getRoleId() == roleId) {
				return oldFriend;
			}
		}
		return null;
	}

	public void addTempFriend(MmochatPlayer friend) {
		try {
			MmochatFriend oldFriend = getFriendFromTemp(friend.getRoleId());
			if (oldFriend != null) {
				return;
			}
			if (myTempFriends.size() >= MmochatConstant.maxTempFriendNum) {
				MmochatFriend f = myTempFriends.poll();
				myTempFriendsMap.remove(f.getRoleId());
			}
			MmochatFriend newFriend = new MmochatFriend();
			newFriend.setName(friend.getName());
			newFriend.setRoleId(friend.getRoleId());
			newFriend.setBmpId(friend.getBmpId());
			myTempFriends.add(newFriend);
			myTempFriendsMap.put(newFriend.getRoleId(), newFriend);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public Map<Integer, MmochatFriend> getMyTempFriendsMap() {
		return myTempFriendsMap;
	}

	public void setMyTempFriendsMap(Map<Integer, MmochatFriend> myTempFriendsMap) {
		this.myTempFriendsMap = new ConcurrentHashMap<Integer, MmochatFriend>(
				myTempFriendsMap);
	}

	@Override
	public int getId() {
		return roleId;
	}

	public MmochatRoleStateType getState() {
		return state;
	}

	public boolean isFreeState() {
		return state == MmochatRoleStateType.空闲;
	}

	// 锁定到新的状态
	public synchronized boolean lockState(MmochatRoleStateType newState) {
		if (state != MmochatRoleStateType.空闲) {
			return false;
		}
		this.state = newState;
		return true;
	}

	// 解锁状态
	public synchronized void unLockState() {
		state = MmochatRoleStateType.空闲;
	}

	// 获取状态值
	// 状态值中，是否为好友/临时好友，是相对于he而言的
	public long getStateValue(MmochatPlayer he) {
		long stateValue = 0;
		if (MmochatTeamService.getTeamState(this) == MmochatTeamStateType.队长) {
			stateValue += MmochatRoleMotionStateType.队长状态.getValue();
		}
		if (isInBattle()) {
			stateValue += MmochatRoleMotionStateType.战斗状态.getValue();
		}
		if (hasPropEffect(MmochatPropType.会员周卡.getEffectKey())) {
			stateValue += MmochatRoleMotionStateType.VIP状态.getValue();
		}
		if (hasPropEffect(MmochatPropType.武神光环.getEffectKey())) {
			stateValue += MmochatRoleMotionStateType.武神光环状态.getValue();
		}
		if (hasPropEffect(MmochatPropType.风神护体.getEffectKey())) {
			stateValue += MmochatRoleMotionStateType.风神护体状态.getValue();
		}
		if (he != null && he != this) {
			if (he.getMyTempFriendsMap().get(roleId) != null
					|| he.getMyDearFriends().get(roleId) != null) {
				stateValue += MmochatRoleMotionStateType.好友状态.getValue();
			}
		}
		MmochatPackageGrid flyGrid = myPackage.get(MmochatSuperMachineType.神行法宝
				.getGridId());
		if (flyGrid != null && flyGrid.getObject() != null) {
			int flyLevel = flyGrid.getObject().getFlyMachineFlyLevel();
			int speedLevel = flyGrid.getObject().getFlyMachineSpeedLevel();
			switch (flyLevel) {
			case 0:
				if (speedLevel == 1) {
					stateValue += MmochatRoleMotionStateType.腾空高度0阶的一级速度状态
							.getValue();
				} else if (speedLevel == 2) {
					stateValue += MmochatRoleMotionStateType.腾空高度0阶的二级速度状态
							.getValue();
				} else if (speedLevel == 3) {
					stateValue += MmochatRoleMotionStateType.腾空高度0阶的三级速度状态
							.getValue();
				}
				break;
			case 1:
				stateValue += MmochatRoleMotionStateType.腾空高度1阶的飞行状态.getValue();
				break;
			case 2:
				stateValue += MmochatRoleMotionStateType.腾空高度2阶的飞行状态.getValue();
				break;
			case 3:
				stateValue += MmochatRoleMotionStateType.腾空高度3阶的飞行状态.getValue();
				break;
			case 4:
				stateValue += MmochatRoleMotionStateType.腾空高度4阶的飞行状态.getValue();
				break;
			case 5:
				stateValue += MmochatRoleMotionStateType.腾空高度5阶的飞行状态.getValue();
				break;
			default:
				break;
			}
			if (flyGrid.getObject().getFlyMachineCanUseValue() <= 0) {
				stateValue += MmochatRoleMotionStateType.飞行器体力不足.getValue();
			}
		}
		if (isAllWeaponedEquipTheSameSet()) {
			stateValue += MmochatRoleMotionStateType.套装状态.getValue();
		}
		if (hasPropEffect(MmochatPropType.超级自动战斗令.getEffectKey())) {
			stateValue += MmochatRoleMotionStateType.无限自动状态.getValue();
		}
		if (getOtherSystemSettingByType(MmochatOtherSystemSettingType.显示战斗背景)) {
			stateValue += MmochatRoleMotionStateType.显示战斗聊天背景.getValue();
		}
		if (getOtherSystemSettingByType(MmochatOtherSystemSettingType.显示雨雪天气)) {
			stateValue += MmochatRoleMotionStateType.显示雨雪天气.getValue();
		}
		return stateValue;
	}

	public int getStoredSmall_money() {
		return storedSmall_money;
	}

	public void setStoredSmall_money(int storedSmallMoney) {
		storedSmall_money = storedSmallMoney;
	}

	public Map<Integer, MmochatPet> getStoredPets() {
		return storedPets;
	}

	public void setStoredPets(Map<Integer, MmochatPet> newPets) {
		// 由于petId会临时生成，故map的key需要重新生成
		storedPets.clear();
		for (MmochatPet pet : newPets.values()) {
			storedPets.put(pet.getId(), pet);
		}
	}

	public void setNoStoredPets() {
		storedPets = new ConcurrentHashMap<Integer, MmochatPet>();
	}

	public void copyStoredPets(Map<Integer, MmochatPet> newPets) {
		storedPets = newPets;
	}

	public boolean isPetStorageFull() {
		return storedPets.size() >= MmochatConstant.maxPetInStorage;
	}

	public void addStoredSmall_money(long addMoney) {
		if ((long) Integer.MAX_VALUE - storedSmall_money < addMoney) {
			storedSmall_money = Integer.MAX_VALUE;
		} else {
			storedSmall_money += addMoney;
			storedSmall_money = Math.max(0, storedSmall_money);
		}
	}

	public void addStoredSmall_money(int addMoney) {
		if ((long) Integer.MAX_VALUE - storedSmall_money < addMoney) {
			storedSmall_money = Integer.MAX_VALUE;
		} else {
			storedSmall_money += addMoney;
			storedSmall_money = Math.max(0, storedSmall_money);
		}
	}

	public Map<Integer, MmochatMovePoint> getPositionBuffer() {
		return positionBuffer;
	}

	public void setPositionBuffer(Map<Integer, MmochatMovePoint> positionBuffer) {
		this.positionBuffer = positionBuffer;
	}

	public int getLogin_time() {
		return login_time;
	}

	public void addLogin_time() {
		login_time++;
	}

	public void setLogin_time(int loginTime) {
		login_time = loginTime;
	}

	public Map<MmochatDailyActivityType, MmochatDailyActivity> getDailyActivities() {
		return dailyActivities;
	}

	public void setDailyActivities(
			Map<MmochatDailyActivityType, MmochatDailyActivity> dailyActivities) {
		this.dailyActivities = new ConcurrentHashMap<MmochatDailyActivityType, MmochatDailyActivity>(
				dailyActivities);
	}

	public void addDailyActivity(MmochatDailyActivity activity) {
		if (activity != null) {
			dailyActivities.put(activity.getType(), activity);
		}
	}

	public Map<Integer, MmochatPropEffect> getPropEffects() {
		return propEffects;
	}

	public void setPropEffects(Map<Integer, MmochatPropEffect> propEffects) {
		this.propEffects = new ConcurrentHashMap<Integer, MmochatPropEffect>(
				propEffects);
	}

	public void delPropEffect(int effectKey) {
		propEffects.remove(effectKey);
	}

	public void addPropEffect(MmochatPropEffect effect) {
		propEffects.put(effect.getPropType().getEffectKey(), effect);
	}

	// 检查时间道具是否有效
	// 或检查计量道具是否还有次数
	public boolean hasPropEffect(int effectKey) {
		MmochatPropEffect effect = propEffects.get(effectKey);
		if (effect == null) {
			return false;
		}
		if (effect.getPropType().getEffectType() == MmochatPropEffectType.时间) {
			if (System.currentTimeMillis() - effect.getStartTime() < effect
					.getRestAmount()) {
				// 时间道具的删除放在统一的地方进行
				return true;
			}
		} else if (effect.getPropType().getEffectType() == MmochatPropEffectType.计量) {
			if (effect.getRestAmount() > 0) {
				return true;
			}
		}
		return false;
	}

	public long getLatest_login_time() {
		return latest_login_time;
	}

	public void setLatest_login_time(long latestLoginTime) {
		latest_login_time = latestLoginTime;
	}

	public MmochatShowRoleSet getShowRoleSet() {
		return showRoleSet;
	}

	public void setShowRoleSet(MmochatShowRoleSet showRoleSet) {
		this.showRoleSet = showRoleSet;
	}

	public Map<MmochatChatChannelType, Boolean> getShowChatSet() {
		return showChatSet;
	}

	public void setShowChatSet(Map<MmochatChatChannelType, Boolean> showChatSet) {
		this.showChatSet = new ConcurrentHashMap<MmochatChatChannelType, Boolean>(
				showChatSet);
	}

	public boolean isAcceptFriendlyPk() {
		return acceptFriendlyPk;
	}

	public void setAcceptFriendlyPk(boolean acceptFriendlyPk) {
		this.acceptFriendlyPk = acceptFriendlyPk;
	}

	public boolean isAcceptZhanjiPk() {
		return acceptZhanjiPk;
	}

	public void setAcceptZhanjiPk(boolean acceptZhanjiPk) {
		this.acceptZhanjiPk = acceptZhanjiPk;
	}

	public boolean isMicroNetFlowMode() {
		if (!microNetFlowMode) {
			if (System.currentTimeMillis() - lastActionTime.get() >= MmochatConstant.roleLeaveTime) {
				microNetFlowMode = true;
				positionBuffer.clear();
				// 进入省流量模式,给玩家下发提示
				String msg = "您已经连续"
						+ (MmochatConstant.roleLeaveTime / MmochatConstant.MS_PER_MINUTE)
						+ "分钟没有活动过了,自动进入"
						+ MmochatUtil.wrapColor("休眠模式", Color.green)
						+ ",此模式下不产生流量。再次活动后将恢复正常游戏模式。";
				MmochatChatService.sendSystemMsgToPerson(this, msg);
			}
		}
		return microNetFlowMode;
	}

	public boolean isDeadInBattle() {
		return isDeadInBattle;
	}

	public void setDeadInBattle(boolean isDead) {
		this.isDeadInBattle = isDead;
	}

	public long getLastGetVipDoublePropTime() {
		return lastGetVipDoublePropTime;
	}

	public void setLastGetVipDoublePropTime(long lastGetVipDoublePropTime) {
		this.lastGetVipDoublePropTime = lastGetVipDoublePropTime;
	}

	public int getBmpId() {
		return bmpId;
	}

	public void setBmpId(int bmpId) {
		this.bmpId = bmpId;
	}

	public String getMoodInfo() {
		return (moodInfo != null) ? moodInfo : "-";
	}

	public void setMoodInfo(String moodInfo) {
		this.moodInfo = moodInfo;
	}

	public Map<Integer, Integer> getMyFans() {
		return myFans;
	}

	public void addFans(int roleId) {
		myFans.put(roleId, roleId);
	}

	public void delFans(int roleId) {
		myFans.remove(roleId);
	}

	public void setMyFans(Map<Integer, Integer> myFans) {
		this.myFans = new ConcurrentHashMap<Integer, Integer>(myFans);
	}

	public Map<Integer, Integer> getOnlineFriends() {
		return onlineFriends;
	}

	public void setOnlineFriends(Map<Integer, Integer> onlineFriends) {
		this.onlineFriends = new ConcurrentHashMap<Integer, Integer>(
				onlineFriends);
	}

	public void addOnlineFriend(int roleId) {
		offlineFriends.remove(roleId);
		onlineFriends.put(roleId, roleId);
	}

	public void addOffLineFriend(int roleId) {
		onlineFriends.remove(roleId);
		offlineFriends.put(roleId, roleId);
	}

	public Map<Integer, Integer> getOfflineFriends() {
		return offlineFriends;
	}

	public void setOfflineFriends(Map<Integer, Integer> offlineFriends) {
		this.offlineFriends = new ConcurrentHashMap<Integer, Integer>(
				offlineFriends);
	}

	public Map<Integer, Integer> getMyIdols() {
		return myIdols;
	}

	public void setMyIdols(Map<Integer, Integer> myIdols) {
		this.myIdols = new ConcurrentHashMap<Integer, Integer>(myIdols);
	}

	public void addMyIdol(int targetRoleId) {
		myIdols.put(targetRoleId, targetRoleId);
	}

	public void delMyIdol(int targetRoleId) {
		myIdols.remove(targetRoleId);
	}

	public boolean isAcceptStrangerMessage() {
		return acceptStrangerMessage;
	}

	public void setAcceptStrangerMessage(boolean acceptStrangerMessage) {
		this.acceptStrangerMessage = acceptStrangerMessage;
	}

	public boolean isCheckAddMeFriend() {
		return checkAddMeFriend;
	}

	public void setCheckAddMeFriend(boolean checkAddMeFriend) {
		this.checkAddMeFriend = checkAddMeFriend;
	}

	public boolean isAcceptAddMeFriend() {
		return acceptAddMeFriend;
	}

	public void setAcceptAddMeFriend(boolean acceptAddMeFriend) {
		this.acceptAddMeFriend = acceptAddMeFriend;
	}

	public int getCommonActivityScore() {
		return commonActivityScore;
	}

	public void setCommonActivityScore(int score) {
		this.commonActivityScore = score;
	}

	public void delCommonActivityScore(int del) {
		commonActivityScore -= del;
		commonActivityScore = Math.max(0, commonActivityScore);
	}

	public void delCommonActivityScoreToHalf() {
		if (commonActivityScore < 2) {
			commonActivityScore = 0;
		} else {
			commonActivityScore = commonActivityScore / 2;
		}
	}

	public void delCommonActivityScoreToOneThird() {
		if (commonActivityScore < 3) {
			commonActivityScore = 0;
		} else {
			commonActivityScore = commonActivityScore / 3;
		}
	}

	public void addCommonActivityScore(int add) {
		commonActivityScore += add;
		commonActivityScore = Math.max(0, commonActivityScore);
	}

	public int getGangId() {
		return gangId;
	}

	public void setGangId(int gangId) {
		this.gangId = gangId;
	}

	public boolean hasGang() {
		return gangId >= 0;
	}

	public void setNoGang() {
		gangId = -1;
	}

	public int getPkteam_id() {
		return pkteam_id;
	}

	public void setPkteam_id(int pkteamId) {
		pkteam_id = pkteamId;
	}

	public boolean hasPkTeam() {
		return pkteam_id >= 0;
	}

	public long getLastTimeOfCancelGangTask() {
		return lastTimeOfCancelGangTask;
	}

	public void setLastTimeOfCancelGangTask(long lastTimeOfCancelGangTask) {
		this.lastTimeOfCancelGangTask = lastTimeOfCancelGangTask;
	}

	public long getLastTimeOfWorldChat() {
		return lastTimeOfWorldChat;
	}

	public void setLastTimeOfWorldChat(long lastTimeOfWorldChat) {
		this.lastTimeOfWorldChat = lastTimeOfWorldChat;
	}

	public Map<MmochatGangSkillType, MmochatGangSkill> getGangSkills() {
		return gangSkills;
	}

	public void setGangSkills(
			Map<MmochatGangSkillType, MmochatGangSkill> gangSkills) {
		this.gangSkills = new ConcurrentHashMap<MmochatGangSkillType, MmochatGangSkill>(
				gangSkills);
	}

	public int getTeacher_roleId() {
		return teacher_roleId;
	}

	public void setTeacher(int teacherRoleId, String name) {
		teacher_roleId = teacherRoleId;
		setTeacher_name(name);
	}

	public void setTeacher_roleId(int id) {
		teacher_roleId = id;
	}

	public int getWife_roleId() {
		return wife_roleId;
	}

	public void setWife_roleId(int wifeRoleId) {
		wife_roleId = wifeRoleId;
	}

	public void setWife(int wifeRoleId, String wifeName) {
		wife_roleId = wifeRoleId;
		wife_name = wifeName;
	}

	public void setNoWife() {
		wife_roleId = -1;
		wife_name = null;
	}

	public String getWife_name() {
		return wife_name;
	}

	public void setWife_name(String wifeName) {
		wife_name = wifeName;
	}

	public boolean hasWife() {
		return wife_roleId != -1;
	}

	public boolean hasTeacher() {
		return teacher_roleId != -1;
	}

	public void setNoTeacher() {
		teacher_roleId = -1;
		teacher_name = null;
	}

	public String getTeacher_name() {
		return teacher_name;
	}

	public void setTeacher_name(String teacherName) {
		teacher_name = teacherName;
	}

	public Map<Integer, String> getStudents() {
		return students;
	}

	public void setStudents(Map<Integer, String> student) {
		this.students = new ConcurrentHashMap<Integer, String>(student);
	}

	public void addStudent(MmochatPlayer stu) {
		students.put(stu.getRoleId(), stu.getName());
	}

	public void addStudent(int roleId, String name) {
		students.put(roleId, name);
	}

	public void delStudent(Integer stuRoleId) {
		students.remove(stuRoleId);
	}

	public boolean isStudentFull() {
		return students.size() >= MmochatConstant.maxStudentNum;
	}

	public int getTeacherScore() {
		return teacherScore;
	}

	public void setTeacherScore(int teacherScore) {
		this.teacherScore = teacherScore;
	}

	public void addTeacherScore(int add) {
		teacherScore += add;
	}

	public String getSocialInfo() {
		String info = "";
		Color titleColor = new Color(176, 172, 104);
		Color contentColor = new Color(216, 212, 104);
		// ID: roleId乘3转16进制
		info += MmochatUtil.wrapColor("ID:", titleColor);
		info += MmochatUtil.wrapColor(Integer.toHexString(getRealRoleId() * 3),
				contentColor);

		// 转生情况
		info += MmochatUtil.wrapColor(" 转生:", titleColor);
		if (life_turn > 0) {
			info += MmochatUtil.wrapColor(life_turn + "转", contentColor);
			if (second_role_type != MmochatSecondRoleType.未转生) {
				info += MmochatUtil.wrapColor(second_role_type.toString(),
						contentColor);
			}
		} else {
			info += MmochatUtil.wrapColor("未转生", contentColor);
		}

		// 配偶
		info += "\n";
		info += MmochatUtil.wrapColor("配偶:", titleColor);
		if (wife_name != null) {
			info += MmochatUtil.wrapColor(wife_name, contentColor);
		} else {
			info += MmochatUtil.wrapColor("-", contentColor);
		}

		// 师傅
		info += "\n";
		info += MmochatUtil.wrapColor("师傅:", titleColor);
		if (teacher_name != null) {
			info += MmochatUtil.wrapColor(teacher_name, contentColor);
		} else {
			info += MmochatUtil.wrapColor("-", contentColor);
		}

		// 徒弟
		info += "\n";
		info += MmochatUtil.wrapColor("徒弟:", titleColor);
		if (students.size() == 0) {
			info += MmochatUtil.wrapColor("-", contentColor);
		} else {
			int i = 0;
			for (String name : students.values()) {
				info += MmochatUtil.wrapColor(name, contentColor);
				i++;
				if (i != students.size()) {
					info += "\n    ";
				}
			}
		}

		// 师德值
		info += "\n";
		info += MmochatUtil.wrapColor("师德值:", titleColor);
		info += MmochatUtil.wrapColor(teacherScore, contentColor);

		return info;
	}

	public int getWatchBattleId() {
		return watchBattleId;
	}

	public void setWatchBattleId(int watchBattleId) {
		this.watchBattleId = watchBattleId;
	}

	public boolean isInWatchingBattle() {
		return watchBattleId != 0;
	}

	public void leaveWatchingBattle() {
		watchBattleId = 0;
	}

	public int getMax_screen_role_num() {
		return max_screen_role_num;
	}

	public void setMax_screen_role_num(int maxScreenRoleNum) {
		max_screen_role_num = maxScreenRoleNum;
	}

	public Map<Integer, MmochatPackageGrid> getMyPackage() {
		return myPackage;
	}

	public void setMyPackage(Map<Integer, MmochatPackageGrid> myPackage) {
		this.myPackage = new ConcurrentHashMap<Integer, MmochatPackageGrid>(
				myPackage);
	}

	// 激活VIP包裹格子
	public void enableVipPackageSpace() {
		List<MmochatPackageGrid> grids = new ArrayList<MmochatPackageGrid>();
		for (int i = MmochatConstant.nonVipPackageGridIndexTail + 1; i <= MmochatConstant.vipPackageGridIndexTail; i++) {
			MmochatPackageGrid grid = myPackage.get(i);
			if (grid == null) {
				grid = new MmochatPackageGrid();
				grid.setGridIndex(i);
				grid.setGridType(MmochatPackageGridType.包裹物品格子);
				myPackage.put(grid.getGridIndex(), grid);
			} else {
				if (!grid.isCanUse()) {
					grids.add(grid);
				}
			}
			grid.setCanUse(true);
		}
		if (grids.size() > 0) {
			Mmochat_5_1S pack = new Mmochat_5_1S();
			pack.setGrids(grids);
			MmochatUtil.sendCommonPack(this, pack);
		}
	}

	// 取消VIP包裹格子
	public void disableVipPackageSpace() {
		List<MmochatPackageGrid> grids = new ArrayList<MmochatPackageGrid>();
		for (int i = MmochatConstant.nonVipPackageGridIndexTail + 1; i <= MmochatConstant.vipPackageGridIndexTail; i++) {
			MmochatPackageGrid grid = myPackage.get(i);
			if (grid == null) {
				grid = new MmochatPackageGrid();
				grid.setGridIndex(i);
				grid.setGridType(MmochatPackageGridType.包裹物品格子);
				myPackage.put(grid.getGridIndex(), grid);
			} else {
				if (grid.isCanUse()) {
					grids.add(grid);
				}
			}
			grid.setCanUse(false);
		}
		if (grids.size() > 0) {
			Mmochat_5_1S pack = new Mmochat_5_1S();
			pack.setGrids(grids);
			MmochatUtil.sendCommonPack(this, pack);
		}
	}

	public boolean isVip() {
		if (propEffects.get(MmochatPropType.会员月卡.getEffectKey()) != null) {
			return true;
		} else {
			return false;
		}
	}

	public void checkVipPackageSpace() {
		if (propEffects.get(MmochatPropType.会员月卡.getEffectKey()) != null) {
			enableVipPackageSpace();
		} else {
			disableVipPackageSpace();
		}
	}

	// 是否有足够的包裹空间
	public boolean hasEnoughPackageSpace(int needGridNum) {
		int spaceNum = 0;
		for (MmochatPackageGrid grid : myPackage.values()) {
			if (grid == null
					|| grid.getGridType() != MmochatPackageGridType.包裹物品格子) {
				continue;
			}
			if (!grid.isCanUse() || grid.getObject() != null) {
				continue;
			}
			spaceNum++;
			if (spaceNum >= needGridNum) {
				return true;
			}
		}
		return spaceNum >= needGridNum;
	}

	// 获取可用的包裹空间
	public int getPackageSpaceNum() {
		int spaceNum = 0;
		for (MmochatPackageGrid grid : myPackage.values()) {
			if (grid == null
					|| grid.getGridType() != MmochatPackageGridType.包裹物品格子) {
				continue;
			}
			if (!grid.isCanUse() || grid.getObject() != null) {
				continue;
			}
			spaceNum++;
		}
		return spaceNum;
	}

	// 计算还能放下多少个特定物品
	public int calRestPackageSpace(MmochatCommonObjectType type,
			boolean canOverlap, boolean canDeal) {

		int spaceNum = 0;
		for (MmochatPackageGrid grid : myPackage.values()) {
			if (grid == null || !grid.isCanUse()) {
				continue;
			}
			if (grid.getGridType() != MmochatPackageGridType.包裹物品格子) {
				continue;
			}
			if (grid.getObject() != null) {
				if (canOverlap) {
					MmochatCommonObject obj = grid.getObject();
					if (obj.getType() == type && obj.isCanDeal() == canDeal) {
						spaceNum += MmochatConstant.maxNumToOverlapOfPackage
								- obj.getOverlapNum();
					}
				}
			} else {
				if (canOverlap) {
					spaceNum += MmochatConstant.maxNumToOverlapOfPackage;
				} else {
					spaceNum++;
				}

			}
		}
		return spaceNum;
	}

	// 获取包裹中的特定物品,使用次数大于0
	public MmochatPackageGrid getPackageGridOfObj(MmochatCommonObjectType type) {
		for (int i = MmochatConstant.packageGridIndexHead; i <= MmochatConstant.vipPackageGridIndexTail; i++) {
			MmochatPackageGrid grid = myPackage.get(i);
			if (grid == null || !grid.isCanUse()) {
				continue;
			}
			if (grid.getGridType() != MmochatPackageGridType.包裹物品格子) {
				continue;
			}
			if (grid.getObject() != null) {
				MmochatCommonObject obj = grid.getObject();
				if (obj.getType() == type && !obj.isUsedOut()) {
					return grid;
				}
			}
		}
		return null;
	}

	// 计算包裹中有多少个特定物品
	public int getPackageObjNum(MmochatCommonObjectType type) {
		int spaceNum = 0;
		for (MmochatPackageGrid grid : myPackage.values()) {
			if (grid == null || !grid.isCanUse()) {
				continue;
			}
			if (grid.getGridType() != MmochatPackageGridType.包裹物品格子) {
				continue;
			}
			if (grid.getObject() != null) {
				MmochatCommonObject obj = grid.getObject();
				if (obj.getType() == type) {
					spaceNum += obj.getOverlapNum();
				}
			}
		}
		return spaceNum;
	}

	// 计算仓库中有多少个特定物品
	public int getStorageObjNum(MmochatCommonObjectType type) {
		int spaceNum = 0;
		for (MmochatPackageGrid grid : myStorage.values()) {
			if (grid == null || !grid.isCanUse()) {
				continue;
			}
			if (grid.getGridType() != MmochatPackageGridType.仓库物品格子) {
				continue;
			}
			if (grid.getObject() != null) {
				MmochatCommonObject obj = grid.getObject();
				if (obj.getType() == type) {
					spaceNum += obj.getOverlapNum();
				}
			}
		}
		return spaceNum;
	}

	// 扣除N个包裹中的特定物品,返回是否成功；扣除前需要检查是否有足够的物品
	public boolean delPackageObj(MmochatCommonObjectType type, int delNum) {
		int restDelNum = delNum;
		List<MmochatPackageGrid> udpateGrids = new ArrayList<MmochatPackageGrid>();
		for (int i = MmochatConstant.packageGridIndexHead; i <= MmochatConstant.vipPackageGridIndexTail; i++) {
			MmochatPackageGrid grid = myPackage.get(i);
			if (grid == null || !grid.isCanUse()) {
				continue;
			}
			if (grid.getGridType() != MmochatPackageGridType.包裹物品格子) {
				continue;
			}
			if (grid.getObject() != null) {
				MmochatCommonObject obj = grid.getObject();
				if (obj.getType() == type) {
					if (obj.getOverlapNum() > restDelNum) {
						obj.addOverlapNum(-1 * restDelNum);
						udpateGrids.add(grid);
						Mmochat_5_1S pack = new Mmochat_5_1S();
						pack.setGrids(udpateGrids);
						MmochatUtil.sendCommonPack(this, pack);
						return true;
					} else {
						restDelNum -= obj.getOverlapNum();
						grid.setObject(null);
						udpateGrids.add(grid);
					}
					if (restDelNum <= 0) {
						Mmochat_5_1S pack = new Mmochat_5_1S();
						pack.setGrids(udpateGrids);
						MmochatUtil.sendCommonPack(this, pack);
						return true;
					}
				}
			}
		}
		return false;
	}

	// 扣除N个包裹中的特定可交易物品,返回是否成功；扣除前需要检查是否有足够的物品
	public boolean delPackageCanDealObj(MmochatCommonObjectType type, int delNum) {
		int restDelNum = delNum;
		List<MmochatPackageGrid> udpateGrids = new ArrayList<MmochatPackageGrid>();
		for (int i = MmochatConstant.packageGridIndexHead; i <= MmochatConstant.vipPackageGridIndexTail; i++) {
			MmochatPackageGrid grid = myPackage.get(i);
			if (grid == null || !grid.isCanUse()) {
				continue;
			}
			if (grid.getGridType() != MmochatPackageGridType.包裹物品格子) {
				continue;
			}
			if (grid.getObject() != null) {
				MmochatCommonObject obj = grid.getObject();
				if (obj.getType() == type && obj.isCanDeal()) {
					if (obj.getOverlapNum() > restDelNum) {
						obj.addOverlapNum(-1 * restDelNum);
						udpateGrids.add(grid);
						Mmochat_5_1S pack = new Mmochat_5_1S();
						pack.setGrids(udpateGrids);
						MmochatUtil.sendCommonPack(this, pack);
						return true;
					} else {
						restDelNum -= obj.getOverlapNum();
						grid.setObject(null);
						udpateGrids.add(grid);
					}
					if (restDelNum <= 0) {
						Mmochat_5_1S pack = new Mmochat_5_1S();
						pack.setGrids(udpateGrids);
						MmochatUtil.sendCommonPack(this, pack);
						return true;
					}
				}
			}
		}
		return false;
	}

	public void delPackageObjById(int id) {
		Mmochat_5_1S pack = new Mmochat_5_1S();
		for (int i = MmochatConstant.packageGridIndexHead; i <= MmochatConstant.vipPackageGridIndexTail; i++) {
			MmochatPackageGrid grid = myPackage.get(i);
			if (grid == null || !grid.isCanUse()) {
				continue;
			}
			if (grid.getGridType() != MmochatPackageGridType.包裹物品格子) {
				continue;
			}
			if (grid.getObject() != null) {
				MmochatCommonObject obj = grid.getObject();
				if (obj.getId() == id) {
					grid.setObject(null);
					pack.addGrid(grid);
					MmochatUtil.sendCommonPack(this, pack);
				}
			}
		}
	}

	// 将东西放到包裹中,返回格子
	public List<MmochatPackageGrid> addObjectToPackage(MmochatCommonObject obj,
			int startGridIndex, int endGridIndex, boolean upate) {
		if (obj == null) {
			return null;
		}
		List<MmochatPackageGrid> grids = new ArrayList<MmochatPackageGrid>();
		// 如果可以叠加，则先尝试叠加到已有格子
		Mmochat_5_1S pack = new Mmochat_5_1S();
		if (obj.isCanOverlap()) {
			for (int i = startGridIndex; i <= endGridIndex; i++) {
				MmochatPackageGrid grid = myPackage.get(i);
				if (!grid.isCanUse()) {
					continue;
				}
				if (grid.getGridType() != MmochatPackageGridType.包裹物品格子) {
					continue;
				}
				if (grid.getObject() != null) {
					MmochatCommonObject gridObj = grid.getObject();
					if (gridObj.isCanOverlap()
							&& gridObj.getOverlapNum() < MmochatConstant.maxNumToOverlapOfPackage
							&& gridObj.getObjectType() == obj.getObjectType()) {
						if (gridObj.getType() == obj.getType()
								&& gridObj.isCanDeal() == obj.isCanDeal()) {
							// 类型一致且能否交易也一致,可叠加
							if (obj.getOverlapNum() + gridObj.getOverlapNum() <= MmochatConstant.maxNumToOverlapOfPackage) {
								gridObj.addOverlapNum(obj.getOverlapNum());

								grids.add(grid);
								if (upate) {
									pack.setGrids(grids);
									MmochatUtil.sendCommonPack(this, pack);
								}
								return grids;
							} else {
								int add = MmochatConstant.maxNumToOverlapOfPackage
										- gridObj.getOverlapNum();
								gridObj.addOverlapNum(add);
								obj.delOverlapNum(add);
								grids.add(grid);
							}
						}
					}
				}
			}
		}
		// 找空格子放置
		for (int i = startGridIndex; i <= endGridIndex; i++) {
			MmochatPackageGrid grid = myPackage.get(i);
			if (grid == null
					|| grid.getGridType() != MmochatPackageGridType.包裹物品格子) {
				continue;
			}
			if (grid.getObject() != null) {
				continue;
			}
			if (!grid.isCanUse()) {
				continue;
			}
			if (obj.getOverlapNum() <= MmochatConstant.maxNumToOverlapOfPackage) {
				grid.setObject(obj);
				grids.add(grid);
				if (upate) {
					pack.setGrids(grids);
					MmochatUtil.sendCommonPack(this, pack);
				}
				return grids;
			} else {
				// 拆包
				MmochatCommonObject newObj = obj.getCloneWithNewId();
				newObj.setOverlapNum(MmochatConstant.maxNumToOverlapOfPackage);
				grid.setObject(newObj);
				grids.add(grid);
				obj.delOverlapNum(MmochatConstant.maxNumToOverlapOfPackage);
			}
		}
		if (upate) {
			pack.setGrids(grids);
			MmochatUtil.sendCommonPack(this, pack);
		}
		return grids;
	}

	public boolean addObjectToPackage(MmochatCommonObject obj) {
		List<MmochatPackageGrid> grids = addObjectToPackage(obj,
				MmochatConstant.packageGridIndexHead,
				MmochatConstant.vipPackageGridIndexTail, true);
		return grids != null && grids.size() > 0;
	}

	public List<MmochatPackageGrid> addObjectToPackage(MmochatCommonObject obj,
			boolean update) {
		return addObjectToPackage(obj, MmochatConstant.packageGridIndexHead,
				MmochatConstant.vipPackageGridIndexTail, update);
	}

	public MmochatCommonObject getPackageObjByGridId(int gridIndex) {
		MmochatPackageGrid grid = myPackage.get(gridIndex);
		if (grid == null) {
			return null;
		}
		return grid.getObject();
	}

	// 计算仓库还能放下多少个特定物品
	public int calRestStorageSpace(MmochatCommonObjectType type,
			boolean canOverlap, boolean canDeal) {
		int spaceNum = 0;
		for (MmochatPackageGrid grid : myStorage.values()) {
			if (!grid.isCanUse()) {
				continue;
			}
			if (grid.getObject() != null) {
				if (canOverlap) {
					MmochatCommonObject obj = grid.getObject();
					if (obj.getType() == type && obj.isCanDeal() == canDeal) {
						spaceNum += MmochatConstant.maxNumToOverlapOfStorage
								- obj.getOverlapNum();
					}
				}
			} else {
				if (canOverlap) {
					spaceNum += MmochatConstant.maxNumToOverlapOfStorage;
				} else {
					spaceNum++;
				}

			}
		}
		return spaceNum;
	}

	// 将东西放到仓库中,返回是否成功
	public boolean addObjectToStorage(MmochatCommonObject obj) {
		if (obj == null) {
			return true;
		}
		// 如果可以叠加，则先尝试叠加到已有格子
		if (obj.isCanOverlap()) {
			for (int i = MmochatConstant.storageGridIndexHead; i <= MmochatConstant.storageGridIndexTail; i++) {
				MmochatPackageGrid grid = myStorage.get(i);
				if (!grid.isCanUse()) {
					continue;
				}
				if (grid.getObject() != null) {
					MmochatCommonObject gridObj = grid.getObject();
					if (gridObj.isCanOverlap()
							&& gridObj.getOverlapNum() < MmochatConstant.maxNumToOverlapOfStorage
							&& gridObj.getObjectType() == obj.getObjectType()) {
						if (gridObj.getType() == obj.getType()
								&& gridObj.isCanDeal() == obj.isCanDeal()) {
							// 类型一致且能否交易也一致,则可叠加
							if (obj.getOverlapNum() + gridObj.getOverlapNum() <= MmochatConstant.maxNumToOverlapOfStorage) {
								gridObj.addOverlapNum(obj.getOverlapNum());
								return true;
							} else {
								int add = MmochatConstant.maxNumToOverlapOfStorage
										- gridObj.getOverlapNum();
								gridObj.addOverlapNum(add);
								obj.delOverlapNum(add);
							}
						}
					}
				}
			}
		}
		// 找空格子放置
		for (int i = MmochatConstant.storageGridIndexHead; i <= MmochatConstant.storageGridIndexTail; i++) {
			MmochatPackageGrid grid = myStorage.get(i);
			if (grid.getObject() != null) {
				continue;
			}
			if (!grid.isCanUse()) {
				continue;
			}
			if (obj.getOverlapNum() <= MmochatConstant.maxNumToOverlapOfStorage) {
				grid.setObject(obj);
				return true;
			} else {
				// 拆包
				MmochatCommonObject newObj = obj.getCloneWithNewId();
				newObj.setOverlapNum(MmochatConstant.maxNumToOverlapOfStorage);
				grid.setObject(newObj);
				obj.delOverlapNum(MmochatConstant.maxNumToOverlapOfStorage);
			}
		}
		return false;
	}

	public Map<Integer, MmochatPackageGrid> getMyStorage() {
		return myStorage;
	}

	public void setMyStorage(Map<Integer, MmochatPackageGrid> myStorage) {
		this.myStorage = new ConcurrentHashMap<Integer, MmochatPackageGrid>(
				myStorage);
	}

	public int getAttack_gift_point() {
		return attack_gift_point;
	}

	public void setAttack_gift_point(int attackGiftPoint) {
		attack_gift_point = attackGiftPoint;
	}

	public void delAttack_gift_point(int del) {
		attack_gift_point -= del;
		attack_gift_point = Math.max(0, attack_gift_point);
	}

	public int getSprit_gift_point() {
		return sprit_gift_point;
	}

	public void setSprit_gift_point(int spritGiftPoint) {
		sprit_gift_point = spritGiftPoint;
	}

	public void delSprit_gift_point(int del) {
		sprit_gift_point -= del;
		sprit_gift_point = Math.max(0, sprit_gift_point);
	}

	public int getBlood_gift_point() {
		return blood_gift_point;
	}

	public void setBlood_gift_point(int bloodGiftPoint) {
		blood_gift_point = bloodGiftPoint;
	}

	public void delBlood_gift_point(int del) {
		blood_gift_point -= del;
		blood_gift_point = Math.max(0, blood_gift_point);
	}

	public int getDefend_gift_point() {
		return defend_gift_point;
	}

	public void setDefend_gift_point(int defendGiftPoint) {
		defend_gift_point = defendGiftPoint;
	}

	public void delDefend_gift_point(int del) {
		defend_gift_point -= del;
		defend_gift_point = Math.max(0, defend_gift_point);
	}

	public int getSpeed_gift_point() {
		return speed_gift_point;
	}

	public void setSpeed_gift_point(int speedGiftPoint) {
		speed_gift_point = speedGiftPoint;
	}

	public void delSpeed_gift_point(int del) {
		speed_gift_point -= del;
		speed_gift_point = Math.max(0, speed_gift_point);
	}

	public int getSpace_gift_point() {
		return space_gift_point;
	}

	public void setSpace_gift_point(int spaceGiftPoint) {
		space_gift_point = spaceGiftPoint;
	}

	public void addSpace_gift_point(int num) {
		space_gift_point += num;
		space_gift_point = Math.max(0, space_gift_point);
	}

	public Map<Integer, MmochatFriend> getMyTempFriendsBak() {
		return myTempFriendsBak;
	}

	public void setMyTempFriendsBak(Map<Integer, MmochatFriend> myTempFriendsBak) {
		this.myTempFriendsBak = new ConcurrentHashMap<Integer, MmochatFriend>(
				myTempFriendsBak);
	}

	@Override
	public boolean isDisappearWhenDie() {
		return false;
	}

	// 身上的套装有几件改20的
	public int getCountOfMaxModifiedWeaponedEquip() {
		List<MmochatEquipPlaceType> places = new ArrayList<MmochatEquipPlaceType>();
		places.add(MmochatEquipPlaceType.头部);
		places.add(MmochatEquipPlaceType.手上);
		places.add(MmochatEquipPlaceType.脚);
		places.add(MmochatEquipPlaceType.身体);
		MmochatEquipGiftType equipGiftType = null;// 套装类型
		Integer equipLevelNeed = null;// 装备等级
		int count = 0;
		for (MmochatEquipPlaceType place : places) {
			MmochatPackageGrid grid = myPackage.get(place.getValue());
			if (grid == null || !grid.isCanUse()) {
				return 0;
			}
			MmochatCommonObject equip = grid.getObject();
			if (equip == null) {
				return 0;
			}
			if (equip.getEquipGiftType() == null) {
				// 不是套装
				return 0;
			}
			// 套装类型检查
			if (equipGiftType == null) {
				equipGiftType = equip.getEquipGiftType();
			} else {
				if (equip.getEquipGiftType() != equipGiftType) {
					// 套装类型不统一
					return 0;
				}
			}
			// 套装等级检查
			if (equipLevelNeed == null) {
				equipLevelNeed = equip.getEquipLevelNeed();
			} else {
				if (equipLevelNeed != equip.getEquipLevelNeed()) {
					// 套装级别不统一
					return 0;
				}
			}
			if (equip.getEquipModifyLevel() >= MmochatConstant.maxEquipModifyLevel) {
				count++;
			}
		}
		return count;
	}

	// 是否身上穿着的头盔、衣服、武器、鞋子是同一类型、等级的套装
	public boolean isAllWeaponedEquipTheSameSet() {
		List<MmochatEquipPlaceType> places = new ArrayList<MmochatEquipPlaceType>();
		places.add(MmochatEquipPlaceType.头部);
		places.add(MmochatEquipPlaceType.手上);
		places.add(MmochatEquipPlaceType.脚);
		places.add(MmochatEquipPlaceType.身体);
		MmochatEquipGiftType equipGiftType = null;// 套装类型
		Integer equipLevelNeed = null;// 装备等级
		for (MmochatEquipPlaceType place : places) {
			MmochatPackageGrid grid = myPackage.get(place.getValue());
			if (grid == null || !grid.isCanUse()) {
				return false;
			}
			MmochatCommonObject equip = grid.getObject();
			if (equip == null) {
				return false;
			}
			if (equip.getEquipGiftType() == null) {
				// 不是套装
				return false;
			}
			// 套装类型检查
			if (equipGiftType == null) {
				equipGiftType = equip.getEquipGiftType();
			} else {
				if (equip.getEquipGiftType() != equipGiftType) {
					// 套装类型不统一
					return false;
				}
			}
			// 套装等级检查
			if (equipLevelNeed == null) {
				equipLevelNeed = equip.getEquipLevelNeed();
			} else {
				if (equipLevelNeed != equip.getEquipLevelNeed()) {
					// 套装级别不统一
					return false;
				}
			}
		}
		return true;
	}

	public long getLatest_offline_time() {
		return latest_offline_time;
	}

	public void setLatest_offline_time(long latestOfflineTime) {
		latest_offline_time = latestOfflineTime;
	}

	public boolean isLockTrans() {
		return lockTrans;
	}

	public void setLockTrans(boolean lockTrans) {
		this.lockTrans = lockTrans;
	}

	public boolean isDeleted() {
		return deleted;
	}

	public void setDeleted(boolean deleted) {
		this.deleted = deleted;
	}

	public int getCur_month_login_day_num() {
		return cur_month_login_day_num;
	}

	public void setCur_month_login_day_num(int curMonthLoginDayNum) {
		cur_month_login_day_num = curMonthLoginDayNum;
	}

	public void addCur_month_login_day_num(int add) {
		cur_month_login_day_num += add;
	}

	public String getSuggestName() {
		return suggestName;
	}

	public void setSuggestName(String suggestName) {
		this.suggestName = suggestName;
	}

	public String getImei() {
		return imei;
	}

	public void setImei(String imei) {
		this.imei = imei;
	}

	public int getSuggestScore() {
		return suggestScore;
	}

	public void setSuggestScore(int suggestScore) {
		this.suggestScore = suggestScore;
	}

	public void addSuggestScore(int add) {
		suggestScore += add;
		suggestScore = Math.max(0, suggestScore);
	}

	public long getCreateTime() {
		return createTime;
	}

	public void setCreateTime(long createTime) {
		this.createTime = createTime;
	}

	public int getRest_award_times() {
		return rest_award_times;
	}

	public void setRest_award_times(int restAwardTimes) {
		rest_award_times = restAwardTimes;
	}

	public void addRest_award_times(int add) {
		rest_award_times += add;
		rest_award_times = Math.max(0, rest_award_times);
	}

	public void delRest_award_times(int del) {
		rest_award_times -= del;
		rest_award_times = Math.max(0, rest_award_times);
	}

	public int getAccount_bigmoney() {
		return account_bigmoney;
	}

	public void setAccount_bigmoney(int accountBigmoney) {
		account_bigmoney = accountBigmoney;
	}

	public synchronized void addAccount_bigmoney(int add) {
		if ((long) Integer.MAX_VALUE - account_bigmoney < add) {
			account_bigmoney = Integer.MAX_VALUE;
		} else {
			account_bigmoney += add;
			account_bigmoney = Math.max(0, account_bigmoney);
		}
	}

	public int getAccount_smallmoney() {
		return account_smallmoney;
	}

	public void setAccount_smallmoney(int accountSmallmoney) {
		account_smallmoney = accountSmallmoney;
	}

	public void addAccount_smallmoney(int add) {
		if ((long) Integer.MAX_VALUE - account_smallmoney < add) {
			account_smallmoney = Integer.MAX_VALUE;
		} else {
			account_smallmoney += add;
			account_smallmoney = Math.max(0, account_smallmoney);
		}
	}

	public int getLottery() {
		return lottery;
	}

	public void setLottery(int lottery) {
		this.lottery = lottery;
	}

	public void addLottery(int add) {
		lottery += add;
		lottery = Math.max(0, lottery);
	}

	public int getSustainedLotteryDays() {
		return sustainedLotteryDays;
	}

	public void setSustainedLotteryDays(int sustainedLotteryDays) {
		this.sustainedLotteryDays = sustainedLotteryDays;
	}

	public long getLastLotteryTime() {
		return lastLotteryTime;
	}

	public void setLastLotteryTime(long lastLotteryTime) {
		this.lastLotteryTime = lastLotteryTime;
	}

	public int getTotal_pay() {
		return total_pay;
	}

	public void setTotal_pay(int totalPay) {
		total_pay = totalPay;
	}

	public long getLastTimeOfRemoteDeal() {
		return lastTimeOfRemoteDeal;
	}

	public void setLastTimeOfRemoteDeal(long lastTimeOfRemoteDeal) {
		this.lastTimeOfRemoteDeal = lastTimeOfRemoteDeal;
	}

	public long getLastTimeOfReceiveMotionData() {
		return lastTimeOfReceiveMotionData;
	}

	public void setLastTimeOfReceiveMotionData(long lastTimeOfReceiveMotionData) {
		this.lastTimeOfReceiveMotionData = lastTimeOfReceiveMotionData;
	}

	public Map<MmochatOtherSystemSettingType, Boolean> getOtherSystemSetting() {
		return otherSystemSetting;
	}

	public void setOtherSystemSetting(
			Map<MmochatOtherSystemSettingType, Boolean> otherSystemSetting) {
		this.otherSystemSetting = new ConcurrentHashMap<MmochatOtherSystemSettingType, Boolean>(
				otherSystemSetting);
	}

	// 其它系统设置，如果没有则默认都是true
	public boolean getOtherSystemSettingByType(
			MmochatOtherSystemSettingType type) {
		if (type == null) {
			return true;
		}
		Boolean ret = otherSystemSetting.get(type);
		if (ret == null) {
			return true;
		}
		return ret;
	}

	public Map<MmochatChenHaoType, MmochatChenHao> getChenHaoMap() {
		return chenHaoMap;
	}

	public void setChenHaoMap(Map<MmochatChenHaoType, MmochatChenHao> chenHaoMap) {
		this.chenHaoMap = new ConcurrentHashMap<MmochatChenHaoType, MmochatChenHao>(
				chenHaoMap);
	}

	public void addAndUpdateChenHao(MmochatChenHao chenhao) {
		if (chenhao == null) {
			return;
		}
		for (MmochatChenHao c : chenHaoMap.values()) {
			c.setInUse(false);
		}
		chenhao.setInUse(true);
		chenHaoMap.put(chenhao.getType(), chenhao);

		if (MmochatMainService.isPlayerOnline(roleId)) {
			Mmochat_1_10S pack = new Mmochat_1_10S();
			pack.setMe(this);
			MmochatUtil.sendCommonPack(this, pack);
		}
	}

	public void delAndUpdateChenHao(MmochatChenHaoType chenhaoType) {
		if (chenhaoType == null) {
			return;
		}
		MmochatChenHao c = chenHaoMap.remove(chenhaoType);
		if (c != null && c.isInUse()
				&& MmochatMainService.isPlayerOnline(roleId)) {
			Mmochat_1_10S pack = new Mmochat_1_10S();
			pack.setMe(this);
			MmochatUtil.sendCommonPack(this, pack);
		}
	}

	public MmochatChenHao getCurChenHao() {
		for (MmochatChenHao chenhao : chenHaoMap.values()) {
			if (chenhao.isInUse()) {
				return chenhao;
			}
		}
		return null;
	}

	public boolean hasChenHaoType(MmochatChenHaoType chenhaoType) {
		for (MmochatChenHao chenhao : chenHaoMap.values()) {
			if (chenhao.getType() == chenhaoType) {
				return true;
			}
		}
		return false;
	}

	public String getCurChenHaoInfo() {
		MmochatChenHao c = getCurChenHao();
		if (c == null) {
			return null;
		} else {
			return c.getName();
		}
	}

	public int getFreeWorldChatNum() {
		return freeWorldChatNum;
	}

	public void setFreeWorldChatNum(int freeWorldChatNum) {
		this.freeWorldChatNum = freeWorldChatNum;
	}

	public void addFreeWorldChatNum(int add) {
		freeWorldChatNum += add;
		freeWorldChatNum = Math.min(freeWorldChatNum,
				MmochatConstant.worldChatBufferSize);
		freeWorldChatNum = Math.max(0, freeWorldChatNum);
	}

	public long getLastTimeOfAddChatNum() {
		return lastTimeOfAddChatNum;
	}

	public void setLastTimeOfAddChatNum(long lastTimeOfAddChatNum) {
		this.lastTimeOfAddChatNum = lastTimeOfAddChatNum;
	}

	public boolean isCanEnterBattle() {
		return canEnterBattle;
	}

	public void setCanEnterBattle(boolean canEnterBattle) {
		this.canEnterBattle = canEnterBattle;
	}

	public int getClientVersion() {
		return clientVersion;
	}

	public void setClientVersion(int clientVersion) {
		this.clientVersion = clientVersion;
	}

	public int getLife_turn() {
		return life_turn;
	}

	public void setLife_turn(int lifeTurn) {
		life_turn = lifeTurn;
	}

	public void addLife_turn(int add) {
		life_turn += add;
		life_turn = Math.min(MmochatConstant.maxLifeTurn, life_turn);
		life_turn = Math.max(0, life_turn);
	}

	public MmochatSecondRoleType getSecond_role_type() {
		return second_role_type;
	}

	public void setSecond_role_type(MmochatSecondRoleType secondRoleType) {
		second_role_type = secondRoleType;
	}

	public long getLock_time_point() {
		return lock_time_point;
	}

	public void setLock_time_point(long lockTimePoint) {
		lock_time_point = lockTimePoint;
	}

	public int getServerInstId() {
		return serverInstId;
	}

	public void setServerInstId(int serverInstId) {
		this.serverInstId = serverInstId;
	}

	public int getRegServerInstId() {
		return regServerInstId;
	}

	public void setRegServerInstId(int regServerInstId) {
		this.regServerInstId = regServerInstId;
	}

	public long getHonor() {
		return honor;
	}

	public void setHonor(long honor) {
		this.honor = honor;
	}

	public void addHonor(long add) {
		this.honor += add;
		honor = Math.max(0, honor);
	}

	public void doubleHonor() {
		honor = honor * 2;
	}

	public void halfHonor() {
		honor = honor / 2;
	}

	public String getStore_pwd() {
		return store_pwd;
	}

	public void setStore_pwd(String storePwd) {
		store_pwd = storePwd;
	}

	public MmochatStorePwdState getStore_pwd_state() {
		return store_pwd_state;
	}

	public void setStore_pwd_state(MmochatStorePwdState storePwdState) {
		store_pwd_state = storePwdState;
	}

	public long getReleaseStorePwdTime() {
		return releaseStorePwdTime;
	}

	public void setReleaseStorePwdTime(long releaseStorePwdTime) {
		this.releaseStorePwdTime = releaseStorePwdTime;
	}

	public boolean isHasCheckStorePwd() {
		return hasCheckStorePwd;
	}

	public void setHasCheckStorePwd(boolean hasCheckStorePwd) {
		this.hasCheckStorePwd = hasCheckStorePwd;
	}

	public long getExtra() {
		return extra;
	}

	public void setExtra(long extra) {
		this.extra = extra;
	}

	public long getLimit_bigmoney() {
		return limit_bigmoney;
	}

	public void setLimit_bigmoney(long limitBigmoney) {
		limit_bigmoney = limitBigmoney;
	}

	public synchronized void addLimit_bigmoney(int addMoney) {
		limit_bigmoney += (long) addMoney;
		limit_bigmoney = Math.max(0, limit_bigmoney);
		limit_bigmoney = Math.min(limit_bigmoney, (long) Integer.MAX_VALUE);
	}

	public Map<MmochatBattleOrderType, MmochatBattleOrder> getBattleOrders() {
		return battleOrders;
	}

	public void setBattleOrders(
			Map<MmochatBattleOrderType, MmochatBattleOrder> fuBenOrders) {
		this.battleOrders = fuBenOrders;
	}

	public void addBattleOrder(MmochatBattleOrderType orderType) {
		MmochatBattleOrder newOrder = new MmochatBattleOrder(orderType);
		battleOrders.put(orderType, newOrder);
	}

	// 每回合过后指令保持回合数减1
	public boolean decreaseBattleOrder() {
		boolean hasRemoved = false;
		for (MmochatBattleOrder s : battleOrders.values()) {
			s.decreaseKeepRound();
			if (s.getKeepRound() <= 0) {
				battleOrders.remove(s.getType());
				hasRemoved = true;
			}
		}
		return hasRemoved;
	}

	public boolean hasBattleOrder(MmochatBattleOrderType type) {
		if (battleOrders == null || battleOrders.size() == 0) {
			return false;
		}
		MmochatBattleOrder s = battleOrders.get(type);
		if (s != null && s.getKeepRound() > 0) {
			return true;
		}
		return false;
	}

	public int getFuBenId() {
		return fuBenId;
	}

	public void setFuBenId(int fuBenId) {
		this.fuBenId = fuBenId;
	}

	public boolean isInFuBenActivity() {
		return fuBenId != 0;
	}

	public void leaveFuBen() {
		fuBenId = 0;
	}

	public Map<MmochatSpecialSkillType, MmochatSpecialSkill> getSpecialSkills() {
		return specialSkills;
	}

	public void setSpecialSkills(
			Map<MmochatSpecialSkillType, MmochatSpecialSkill> specialSkills) {
		this.specialSkills = new ConcurrentHashMap<MmochatSpecialSkillType, MmochatSpecialSkill>(
				specialSkills);
	}

	public void addNewSpecialSkill(MmochatSpecialSkill skill) {
		specialSkills.put(skill.getType(), skill);
	}

	public MmochatSpecialSkill getSpecialSkill(MmochatSpecialSkillType type) {
		return specialSkills.get(type);
	}

	public int getSpecialSkillLevel(MmochatSpecialSkillType type) {
		int level = 0;
		MmochatSpecialSkill skill = specialSkills.get(type);
		if (skill != null) {
			level = skill.getLevel();
		}
		return level;
	}

	public long getLastOnlineAwardTick() {
		return lastOnlineAwardTick;
	}

	public void setLastOnlineAwardTick(long lastOnlineAwardTick) {
		this.lastOnlineAwardTick = lastOnlineAwardTick;
	}

	public long getLastOrderStorageTick() {
		return lastOrderStorageTick;
	}

	public void setLastOrderStorageTick(long lastOrderStorageTick) {
		this.lastOrderStorageTick = lastOrderStorageTick;
	}

	public boolean canOrderStorage() {
		return System.currentTimeMillis() - lastOrderStorageTick > MmochatConstant.intevalOfOrderStorage;
	}

	public int getRestOrderSec() {
		return (int) ((MmochatConstant.intevalOfOrderStorage - (System
				.currentTimeMillis() - lastOrderStorageTick)) / MmochatConstant.MS_PER_SECOND);
	}

	public int getMonitorPropNum() {
		return monitorPropNum;
	}

	public void setMonitorPropNum(int monitorPropNum) {
		this.monitorPropNum = monitorPropNum;
	}

	// 计算包裹和仓库中总共有多少个特定道具
	public int calPropNumOfPackageAndStorage(MmochatPropType monitorPropType) {
		int num = 0;
		for (MmochatPackageGrid grid : myPackage.values()) {
			if (grid == null || !grid.isCanUse()) {
				continue;
			}
			if (grid.getGridType() != MmochatPackageGridType.包裹物品格子) {
				continue;
			}
			if (grid.getObject() != null) {
				MmochatCommonObject obj = grid.getObject();
				if (obj.getPropType() != null && monitorPropType != null
						&& obj.getPropType() == monitorPropType) {
					num += obj.getOverlapNum();
				}
			}
		}
		for (MmochatPackageGrid grid : myStorage.values()) {
			if (grid == null || !grid.isCanUse()) {
				continue;
			}
			if (grid.getGridType() != MmochatPackageGridType.仓库物品格子) {
				continue;
			}
			if (grid.getObject() != null) {
				MmochatCommonObject obj = grid.getObject();
				if (obj.getPropType() != null && monitorPropType != null
						&& obj.getPropType() == monitorPropType) {
					num += obj.getOverlapNum();
				}
			}
		}
		return num;
	}

	// 返回包裹中的特定道具的格子
	public MmochatPackageGrid getPropGridFromPackage(MmochatPropType propType) {
		for (MmochatPackageGrid grid : myPackage.values()) {
			if (grid == null || !grid.isCanUse()) {
				continue;
			}
			if (grid.getGridType() != MmochatPackageGridType.包裹物品格子) {
				continue;
			}
			if (grid.getObject() != null) {
				MmochatCommonObject obj = grid.getObject();
				if (obj.getPropType() != null && propType != null
						&& obj.getPropType() == propType) {
					if (!obj.isUsedOut()) {
						return grid;
					}
				}
			}
		}
		return null;
	}

	// 监控一个操作中是否有道具非法增加：
	// 1、在此操作前setPropNumBeforeTask，取得操作前的道具数量
	// 2、如果在操作过程中，有合理的道具数量变化，需要通过addMonitorPropNum来增减道具数量
	// 3、在此操作后checkPropNumAfterTask，检查道具数量是否合法
	public void setPropNumBeforeTask() {
		try {
			if (MmochatConstant.isMonitorLogOpen
					&& MmochatConstant.monitorPropType != null) {
				monitorPropNum = calPropNumOfPackageAndStorage(MmochatConstant.monitorPropType);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void addMonitorPropNum(MmochatPropType propType, int add) {
		try {
			if (MmochatConstant.isMonitorLogOpen
					&& MmochatConstant.monitorPropType != null
					&& propType != null
					&& propType == MmochatConstant.monitorPropType) {
				monitorPropNum += add;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void checkPropNumAfterTask(String taskDetail) {
		try {
			if (MmochatConstant.isMonitorLogOpen
					&& MmochatConstant.monitorPropType != null) {
				int newCount = calPropNumOfPackageAndStorage(MmochatConstant.monitorPropType);
				if (newCount != monitorPropNum) {
					// 数量不符合
					MmochatUtil.monitorLog(MmochatConstant.monitorPropType
							.toString()
							+ " 合理值:"
							+ monitorPropNum
							+ ",实际:"
							+ newCount
							+ "!roleId:" + roleId + "." + taskDetail);
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public int getPk_score() {
		return pk_score;
	}

	public void setPk_score(int pkScore) {
		pk_score = pkScore;
	}

	public void addPk_score(int add) {
		pk_score += add;
		pk_score = Math.max(0, pk_score);
	}

	public long getLatest_pay_time() {
		return latest_pay_time;
	}

	public void setLatest_pay_time(long latestPayTime) {
		latest_pay_time = latestPayTime;
	}

	public Map<MmochatLifeSkillType, MmochatLifeSkill> getLifeSkills() {
		return lifeSkills;
	}

	public void setLifeSkills(
			Map<MmochatLifeSkillType, MmochatLifeSkill> lifeSkills) {
		this.lifeSkills = new ConcurrentHashMap<MmochatLifeSkillType, MmochatLifeSkill>(
				lifeSkills);
	}

	public void addNewLifeSkill(MmochatLifeSkill skill) {
		lifeSkills.put(skill.getType(), skill);
	}

	public MmochatLifeSkill getLifeSkill(MmochatLifeSkillType type) {
		return lifeSkills.get(type);
	}

	public int getLifeSkillLevel(MmochatLifeSkillType type) {
		int level = 0;
		MmochatLifeSkill skill = lifeSkills.get(type);
		if (skill != null) {
			level = skill.getLevel();
		}
		return level;
	}

	public MmochatRoleBmpType getCurRoleBmpType() {
		return curRoleBmpType;
	}

	public void setCurRoleBmpType(MmochatRoleBmpType curRoleBmpType) {
		this.curRoleBmpType = curRoleBmpType;
	}

	public void resetCurRoleBmpType() {
		curRoleBmpType = getBmpType();
	}

	public long getLastTimeOfReceiveWorldChat() {
		return lastTimeOfReceiveWorldChat;
	}

	public void setLastTimeOfReceiveWorldChat(long lastTimeOfReceiveWorldChat) {
		this.lastTimeOfReceiveWorldChat = lastTimeOfReceiveWorldChat;
	}

	public boolean canReceiveWorldChat() {
		return System.currentTimeMillis() - lastTimeOfReceiveWorldChat > MmochatConstant.minIntervalOfFreeWorldChat;
	}

	public long getHeartBeatStartTick() {
		return heartBeatStartTick;
	}

	public void setHeartBeatStartTick(long heartBeatStartTick) {
		this.heartBeatStartTick = heartBeatStartTick;
	}

	public int getHeartBeatTimes() {
		return heartBeatTimes;
	}

	public void setHeartBeatTimes(int heartBeatTimes) {
		this.heartBeatTimes = heartBeatTimes;
	}

	public void addHeartBeatTimes() {
		heartBeatTimes++;
	}

	// 是否有押镖任务
	@SuppressWarnings("deprecation")
	public boolean hasYBTask() {
		Date now = new Date();
		if (now.getDay() != 6) {
			return false;
		}
		if (now.getHours() != 21) {
			return false;
		}
		MmochatTaskType[] subTaskTypes = new MmochatTaskType[] {
				MmochatTaskType.押送镖银之消灭饕餮, MmochatTaskType.押送镖银之消灭巫妖,
				MmochatTaskType.押送镖银之消灭蟹将, MmochatTaskType.押送镖银之消灭彼岸花,
				MmochatTaskType.押送镖银 };
		for (MmochatTaskType taskType : subTaskTypes) {
			MmochatTask task = getTaskByType(taskType);
			if (task != null && !task.isInvalid()
					&& task.getTaskState() != MmochatTaskStateType.已完成) {
				// 有此任务、任务未过期、任务未完成
				return true;
			}
			// 无此任务，或任务已过期，或任务已完成
		}
		return false;
	}

	public long getLastTimeOfPrivateChat() {
		return lastTimeOfPrivateChat;
	}

	public void setLastTimeOfPrivateChat(long lastTimeOfPrivateChat) {
		this.lastTimeOfPrivateChat = lastTimeOfPrivateChat;
	}

	public int getRecordBattleId() {
		return recordBattleId;
	}

	public void setRecordBattleId(int recordBattleId) {
		this.recordBattleId = recordBattleId;
	}

	// TODO:GSON分割线
	public String getGson_tasks() {
		if (tasks == null) {
			return null;
		}
		Gson gson = new Gson();
		return gson.toJson(tasks, new TypeToken<Map<Integer, MmochatTask>>() {
		}.getType());
	}

	public String getGson_skills() {
		if (skills == null) {
			return null;
		}
		Gson gson = new Gson();
		return gson.toJson(skills,
				new TypeToken<Map<MmochatSkillType, MmochatSkill>>() {
				}.getType());
	}

	public String getGson_pets() {
		if (pets == null) {
			return null;
		}
		Gson gson = new Gson();
		return gson.toJson(pets, new TypeToken<Map<Integer, MmochatPet>>() {
		}.getType());
	}

	public String getGson_friends() {
		if (myDearFriends == null) {
			return null;
		}
		Gson gson = new Gson();
		return gson.toJson(myDearFriends,
				new TypeToken<Map<Integer, MmochatFriend>>() {
				}.getType());
	}

	public String getGson_enermys() {
		if (myEnermys == null) {
			return null;
		}
		Gson gson = new Gson();
		return gson.toJson(myEnermys,
				new TypeToken<Map<Integer, MmochatFriend>>() {
				}.getType());
	}

	public String getGson_stored_pets() {
		if (storedPets == null) {
			return null;
		}
		Gson gson = new Gson();
		return gson.toJson(storedPets,
				new TypeToken<Map<Integer, MmochatPet>>() {
				}.getType());
	}

	public String getGson_dailyActivities() {
		if (dailyActivities == null) {
			return null;
		}
		Gson gson = new Gson();
		return gson
				.toJson(
						dailyActivities,
						new TypeToken<Map<MmochatDailyActivityType, MmochatDailyActivity>>() {
						}.getType());
	}

	public String getGson_propEffects() {
		if (propEffects == null) {
			return null;
		}
		Gson gson = new Gson();
		return gson.toJson(propEffects,
				new TypeToken<Map<MmochatPropEffectType, MmochatPropEffect>>() {
				}.getType());
	}

	public String getGson_showChat() {
		if (showChatSet == null) {
			return null;
		}
		Gson gson = new Gson();
		return gson.toJson(showChatSet,
				new TypeToken<Map<MmochatChatChannelType, Boolean>>() {
				}.getType());
	}

	public String getGson_myFans() {
		if (myFans == null) {
			return null;
		}
		Gson gson = new Gson();
		return gson.toJson(myFans, new TypeToken<Map<Integer, Integer>>() {
		}.getType());
	}

	public String getGson_myIdols() {
		if (myIdols == null) {
			return null;
		}
		Gson gson = new Gson();
		return gson.toJson(myIdols, new TypeToken<Map<Integer, Integer>>() {
		}.getType());
	}

	public String getGson_gangSkills() {
		if (gangSkills == null) {
			return null;
		}
		Gson gson = new Gson();
		return gson.toJson(gangSkills,
				new TypeToken<Map<MmochatGangSkillType, MmochatGangSkill>>() {
				}.getType());
	}

	public String getGson_students() {
		if (students == null) {
			return null;
		}
		Gson gson = new Gson();
		return gson.toJson(students, new TypeToken<Map<Integer, String>>() {
		}.getType());
	}

	public String getGson_myPackage() {
		if (myPackage == null) {
			return null;
		}
		Gson gson = new Gson();
		return gson.toJson(myPackage,
				new TypeToken<Map<Integer, MmochatPackageGrid>>() {
				}.getType());
	}

	public String getGson_myStorage() {
		if (myStorage == null) {
			return null;
		}
		Gson gson = new Gson();
		return gson.toJson(myStorage,
				new TypeToken<Map<Integer, MmochatPackageGrid>>() {
				}.getType());
	}

	public String getGson_otherSystemSetting() {
		if (otherSystemSetting == null) {
			return null;
		}
		Gson gson = new Gson();
		return gson.toJson(otherSystemSetting,
				new TypeToken<Map<MmochatOtherSystemSettingType, Boolean>>() {
				}.getType());
	}

	public String getGson_chenhao() {
		if (chenHaoMap == null) {
			return "{}";
		}
		Gson gson = new Gson();
		return gson.toJson(chenHaoMap,
				new TypeToken<Map<MmochatChenHaoType, MmochatChenHao>>() {
				}.getType());
	}

	public String getGson_specialSkills() {
		if (specialSkills == null) {
			return "{}";
		}
		Gson gson = new Gson();
		return gson
				.toJson(
						specialSkills,
						new TypeToken<Map<MmochatSpecialSkillType, MmochatSpecialSkill>>() {
						}.getType());
	}

	public String getGson_lifeSkills() {
		if (lifeSkills == null) {
			return "{}";
		}
		Gson gson = new Gson();
		return gson.toJson(lifeSkills,
				new TypeToken<Map<MmochatLifeSkillType, MmochatLifeSkill>>() {
				}.getType());
	}

	public static class sortByCommonScore implements Comparator<MmochatPlayer> {
		// 降序
		@Override
		public int compare(MmochatPlayer arg0, MmochatPlayer arg1) {
			return arg1.getCommonActivityScore()
					- arg0.getCommonActivityScore();
		}

	}

	@Override
	public int compareTo(MmochatPlayer other) {
		return other.getPk_score() - pk_score;
	}

}
